An AT&T 3B2/400 Simulator

3b2_emulator_screenshot.jpg

Table of Contents

1. Introduction

The AT&T 3B2/400 was a small, multi-user UNIX computer developed by AT&T in 1985. It was part of the larger 3B family of UNIX computers based on the Western Electric WE32000 and WE32100 series of CPUs and peripherals. What makes the 3B2 historically interesting was its use as the primary porting platform for AT&T UNIX System V Release 3.

This simulator is part of the SIMH simulation framework, and emulates a standard desktop 3B2/400 with the following devices:

  • WE32100 CPU
  • WE32101 MMU
  • WE32106 MAU
  • 1MB, 2MB, or 4MB of system memory
  • One 720KB floppy diskette
  • One or two 30MB, 72MB, 135MB, or 161MB MFM hard disk drives.
  • One 23MB QIC Cartridge Tape (CTC)
  • One Ethernet Network Interface (NI)
  • Up to twelve 4-port serial cards for remote terminals (PORTS)

Since internals documentation for the 3B2 series were not readily available, the simulator was originally made possible through a reverse-engineering effort, studying the System V Release 3 source code, and lots of caffeine.

2. Changelog

2019-07-01
Fixed a bug in integer addition that could fail to set the overflow (V) flag in the PSW. Added support for SIMH's clock precalibration.
2019-06-29
Added support for the WE32106 Math Acceleration Unit (MAU) device, required for some later software binaries.
2019-03-09
Added support for the Network Interface (NI) Ethernet expansion card.
2019-01-14
Renamed floppy disk device to IFLOPPY, and hard disk device to IDISK, to avoid conflicts with SIMH built-in command names. Also fixed a bug that prevented the simulator from using read-only floppy disk images.
2018-12-13
Fix for DUART initialization that prevented automatic reboot.
2018-08-19
Fix for CTC and PORTS cards overwriting kernel memory
2018-07-13
Several timing and terminal fixes from upstream SIMH.
2018-05-22
Fix for critical floppy timing issue.
2018-05-21
Support for CIO ("Common IO") expansion cards. PORTS and CTC cards are now supported. PORTS cards each provide 4 serial lines, and up to 4 PORTS cards are supported. CTC cards provide a 23MB Cipher "FloppyTape" tape backup solution. One CTC card is supported.
2018-04-11
Major fix to DMA and CONTTY serial support.
2017-12-27
HD135 and HD161 are now both recognized names for the Maxtor XT-2190 disk drive.
2017-12-27
Fix for CPU traps. The UNIX debugger sdb should now work correctly under System V Release 3.
2017-12-17
Minor compiler warning fix.
2017-12-16
Fixed a FIFO overflow bug in the CONTTY device.
2017-12-15
Critical MMU bugfix.
2017-12-13
Improved support for multiple hard disk drives, as well as adding support for additional hard disk geometries.
2017-12-09
Added support for the secondary on-board serial terminal (CONTTY).

3. Getting the Simulator

The source code is open source, and is available on GitHub from the official SIMH repository.

3.1. Building on GNU/Linux or macOS

Building on GNU/Linux or macOS is fairly straightforward:

  • Clone the SIMH repository listed above
  • cd into the simh directory
  • Type make 3b2

The binary will be built into the ./BIN/ directory.

If any additional libraries are required, the build process will alert you to the fact and let you know what you need.

3.2. Windows XP / 7 / 8 / 10

The standard way to build on Windows is with Visual Studio. Visual Studio Express 2008 is required at a minimum, and is used as the baseline for all SIMH projects.

Simply open the following two projects in a new solution:

  • Visual Studio Projects\BuildROMs.vcproj
  • Visual Studio Projects\3B2.vcproj

Make sure the 3B2 project depends on the BuildROMs project. You should then be able to build.

(Please note: Visual Studio 2019 is not yet supported as of June 2019)

4. Getting Software

The 3B2 line ran AT&T UNIX System V as its native operating system. To my knowledge, no other operating system was ever ported to them.

The very earliest 3B2s shipped with AT&T UNIX System V Release 1, but they almost immediately started shipping with AT&T UNIX System V Release 2, and after it became available, Release 3.

The last version of System V supported by the 3B2/310 and 3B2/400 was System V Release 3.2. Later 3B2 computers, such as the 3B2/600 and 3B2/1000, could run System V Release 4.

4.1. Installing UNIX From Scratch

If you would like to install UNIX from scratch, there is now a guide that will walk you through every step.

I encourage you to try this method, but if you don't want to go through all that work, keep reading.

4.2. Using A Prebuilt Hard Disk Image

To make getting started as painless as possible, I have prepared several hard disk images with AT&T System V Release 3.2 UNIX pre-installed.

All disk images are of the type HD161, to give you maximum free space. They were built on a simulator configured with:

  • 4 MB RAM
  • CTC tape controller enabled
  • Two PORTS serial MUX cards enabled (8 serial lines total)

To use any of the images below, simply download it, uncompress it, rename the uncompressed file to hd161.img, use the supplied boot.ini file (editing it to suit your own needs), and start the simulator.

The UNIX installations on these images are pristine and have not been configured. No system passwords have been set. You will have to log in as the setup user to do a system setup.

File Size Description
boot.ini 307 bytes Simulator Configuration File
base.img.gz 1.8 MB Base UNIX [1]
full.img.gz 4.3 MB Full Install [2]
devel.img.gz 6.4 MB Developer Tools [3]
extras_gnu_src.img.gz 16 MB Extras, GNU, and Source [4]
  1. The Base UNIX image holds a minimal installation of the first six Essential Utilities disks, along with the Cartridge Tape Utilities and CTC driver, but nothing else.
  2. The Full Install image starts with the Base UNIX image, but also includes all 21 disks of the Utilities packages:
    • System Administration Utilities
    • Directory and File Maintenance Utilities
    • User Environment Utilities
    • Inter-Process Communication Utilities
    • Terminal Filter Utilities
    • Terminal Information Utilities
      • All terminfo files installed
    • Graphics Utilities
    • Basic Networking Utilities (UUCP)
    • Editing Utilities
    • Help Utilities
    • Line Printer Spooling Utilities
    • Performance Analysis Utilities
    • Spell Utilities
  3. The Developer Tools image starts with the Full Install, as above, but also adds:
    • Software Generation Utilities: Issue 4 Version 2
    • Extended Software Generation Utilities: Issue 4 Version 1
    • C Programming Language: Issue 4 Version 2
    • System Header Files (3.2)
    • Advanced C Utilities: Issue 4 Version 1
    • Source Code Control Utilities
  4. Finally, the Extras, GNU, and Source image starts with the Developer Tools, as above, but adds the following extras:
    • AT&T UNIX System V Release 3.2 Source Code Provision installed under /usr/src — you could rebuild the entire system from source if you wanted to.
    • C-Kermit 5A(189) installed as /usr/bin/kermit
    • GNU gcc and g++ 2.3.3 under /usr/local
    • GNU make 3.75 installed under /usr/local
    • GNU tar 1.13 installed under /usr/local
    • GNU gzip 1.2.4 insatlled under /usr/local
    • GNU bison 1.25 installed under /usr/local

5. Usage

The 3B2 simulator is part of SIMH, the Computer History Simulation Project. Full documentation for the SIMH platform is availble here:

A complete description of SIMH would be much too long for this document, but in brief, it is a platform for writing and hosting computer simulators. SIMH implements a great number of simulators, of which the 3B2/400 is only one.

Below is a "Getting Started" guide to help ease you into the world of SIMH in general, and using the 3B2/400 specifically.

5.1. Getting Started

The 3b2 binary (or 3B2.exe under Windows) is a standalone application. On Linux, all you need to do is CD into the directory where you've downloaded 3b2, and type:

$ ./3b2

On Windows, open the cmd.exe shell, CD into the directory where you've downloaded 3B2.exe, and type:

C:\some\directory> 3B2

In either case, you will be greeted with an interactive SIMH shell where you can type commands. It looks like this:

AT&T 3B2 Model 400 simulator V4.0-0 Current        git commit id: d11700e0
sim>

To quit at any time, just type quit and press the Enter key.

5.2. Example Startup File

Any command that you can type to the SIMH sim> prompt can be stored in a startup file, and this is generally the easiest way to do things. For example, you may create a file named boot.ini, and enter the following commands:

set cpu 4M
set cpu idle

set mau enable

set idisk0 HD161
attach idisk0 hard_disk.img

attach ifloppy floppy_disk.img

attach nvram nvram.bin
attach tod tod.bin

attach contty 8000

set ctc enable

set ports enable
set ports lines=16
attach ports 9000

When you start the 3B2 simulator, you can pass the name of this file to the program as an argument, for example under Linux

./3b2 boot.ini

And under Windows

C:\some\directory> 3B2 boot.ini

This will launch the simulator and run all the commands in the file.

We'll look at all of the options specified in this example file in greater detail below

5.3. Simulator Options

CPU Memory

set cpu 4M

This line sets the available system memory to 4MB, which is the maximum amount that a 3B2/400 could address. Other options are 1M and 2M.

IDLE support

set cpu idle

This enables CPU idle support. Idle support lets the simulator use less host CPU. If this line were not present, the simulator would use 100% of one host CPU core.

MAU (Math Acceleration Unit)

set mau enable

This line enables the math acceleration co-processor, a WE32106. The WE32106 was an optional part that could be installed onto the system board of a 3B2/310 or 3B2/400. It is automatically detected by the operating system if it is present. If it is enabled, UNIX will use hardware floating point routines. If it is not enabled, UNIX will use floating point emulation.

(For context, many 3B2/310s and 3B2/400s shipped without the MAU installed, since it was an extra cost. Later models of the 3B2, including the 3B2/600 and 3B2/1000, had a WE32106 or WE32206 MAU as standard equipment)

Hard Disk Type

set idisk0 HD161

This command tells the simulator what type of hard disk is attached. idisk0 is the first emulated hard disk drive (idisk stands for "Integrated Disk"). A second hard disk may optionally be attached as idisk1.

HD161 tells the simulator that the hard disk is a Maxtor XT-2190 161MB MFM hard disk.

Other options include HD30 for a 30MB hard disk, and HD72 for a 72MB hard disk.

Unless otherwise specified, HD72 is the default, because a 72MB hard disk was the largest that AT&T originally shipped with the 3B2/400.

Hard Disk Image

attach idisk0 hard_disk.img

This line attaches the disk idisk0 to a virtual hard disk file named hard_disk.img, creating the file if it doesn't exist.

Note that the 3B2/400 expects hard disks to be low-level formatted before they can be used. That is addressed later in this document.

Floppy Disk Image

attach ifloppy floppy_disk.img

This line, similar to the line above, attaches a virtual floppy disk image to the floppy drive. (ifloppy for "Integrated Floppy")

The 3B2/400 floppy disk uses double sided 80-track diskettes with 9 tracks per sector and 512 bytes per track, for a total disk size of 720KB.

NVRAM and Time-of-Day Clock

attach nvram nvram.bin
attach tod tod.bin

These two lines create files to store the state of NVRAM (Non-Volatile RAM) and the Time-of-Day Clock. When these devices are attached, the 3B2/400 simulator will remember important settings and the current time of day between boots.

CONTTY Serial Port

attach contty 8000

All 3B2/400s have two serial ports on the system board: One for the console terminal, labled CONSOLE, and one for a second serial connection, labeled CONTTY. This command enables the secondary serial port and attaches it to Telnet port 9000. You can then use a Telnet client to connect to the host that the simulator is running on on port 8000, and you will be connected to the virtual CONTTY serial line.

CTC Tape Drive

set ctc enable
attach ctc tape.img

This enables the Cartridge Tape Controller (CTC) card. This is a 23 MB Cipher "FloppyTape" QIC tape device present on 3B2/400 computers. The virtual tape drive may be connected to a file with the command attach ctc <filename>

PORTS Serial Ports

set ports enable
set ports lines=16
attach ports 9000

The PORTS card is an optional expansion card for the 3B2/400. Each PORTS card supports 4 serial terminals, and up to 4 PORTS cards may be installed in a 3B2/400.

These commands enabled PORTS support, sets the number of simulated terminal lines to 16 (4 cards), and listens for connections on port 9000.

5.4. Booting The 3B2/400

To boot the simulated 3B2/400, type:

sim> boot

You may see several different messages.

First Time Booting

If you have never booted the 3B2/400 before, or if you have deleted the nvram.bin NVRAM file, you will see the message

FW ERROR 1-01: NVRAM SANITY FAILURE
               DEFAULT VALUES ASSUMED
               IF REPEATED, CHECK THE BATTERY

This is normal. Once the 3B2/400 has booted at least one time, and stored its settings into NVRAM, this message should not be repeated.

Disk Not Formatted Yet

If the hard disk image you've attached idisk0 to has not been formatted yet, or if no disk image is attached, you will see the following message.

FW ERROR 1-02: DISK SANITY FAILURE
               EXECUTION HALTED

Once the disk image has been formatted, or if you use a pre-built image from below, you should no longer see this message.

System Failure Prompt

If either of the above messages appear, or if UNIX has not yet been installed, you will see the following message

SYSTEM FAILURE: CONSULT YOUR SYSTEM ADMINISTRATION UTILITIES GUIDE

IMPORTANT: The SYSTEM FAILURE line is actually an invisible password prompt!

Type the default system maintenance password, which is mcp, and press Enter to continue.

Booting UNIX

Once you've entered the mcp password, you should see the message

Enter name of program to execute [ ]:

Simply type unix and press Enter.

Finally, you will be asked which device to boot from.

	Possible load devices are:

Option Number    Slot     Name
---------------------------------------
       0          0     FD5
       1          0     HD161-B

Enter Load Device Option Number [1 (HD161-B)]:

Enter 0 to boot from the floppy disk, or 1 to boot from the hard disk.

Automatic Boot

Once UNIX has been installed to the hard disk, the system always boots automatically from the first hard disk.

5.5. Exiting the Simulator

To stop SIMH at any time, type the control sequence Control-E. This will return you to the SIMH prompt (sim>), where you can type quit.

6. Transferring Data Between the Simulator and a Host

One interesting challenge is, "How do we share data between the host system and the emulated 3B2?"

There are three options available for this, ranging from simplest to hardest.

6.1. C-Kermit

C-Kermit is a very simple program that transfers data over serial lines. It's very easy to use. The main downside is that transfers are very slow. They're limited to the speed of the emulated serial port, which is 9,600 baud by default, and cannot go above 115,200 bps.

Caveat: On the emulated 3B2, the size of file you can transfer is limited by the ulimit setting, and by default cannot be more than 1MB in size. You may increase the ulimit to overcome this limitation.

To use Kermit, you will need two pieces of software:

  1. Kermit for your host operating system
  2. C-Kermit for the 3B2 (below).

Kermit 95 for Windows is available here: http://www.kermitproject.org/k95.html

C-Kermit for Linux is available through most distribution's package managers.

C-Kermit for the 3B2 is available here, on a diskette image:

Image Size Description
CKermit_189.img 720 KB C-Kermit 5A(189) compiled for SVR3.2 on the 3B2/400

Installing Kermit on the Simulator

NOTE: You can skip this step if you have used the pre-built hard disk image from above, because it already includes C-Kermit 5A(189) pre-installed.

To install C-Kermit, first attach the floppy image to the simulator with the following command:

sim> ATTACH IFLOPPY ck189.img

Then, in SVR3 UNIX, mount the floppy:

# mount /dev/diskette /install
# cp /install/kermit /usr/bin/kermit

Finally, unmount the floppy image

# umount /dev/diskette

Copying Data from the Host Computer to the 3B2

  1. Enable the CONTTY or a PORTS device on the 3B2. For example, to listen for connections on port 8888, you would add this to your startup file:

    ATTACH CONTTY 8888
    

    or

    ENABLE PORTS
    SET PORTS LINES=8
    ATTACH PORTS 8888
    
  2. Start Kermit on your host system.
  3. From C-Kermit on your host system, use the following command to connect to the CONTTY device:

    C-Kermit> TELNET /NOWAIT 127.0.0.1 8888
    

    Be sure to replace the IP address and port with the appropriate values.

  4. When Kermit has connected to the CONTTY device, press Enter a few times until you see a login prompt. Log in as your standard user on the 3B2.
  5. Now, on the 3B2, run C-Kermit, and type:

    C-Kermit> RECEIVE
    

    followed by the control sequence to bring you back to the host Kermit interface:

    <Control>-\ c
    

    (that’s the Control key plus backslash (\), followed by the “c” key)

  6. You should now be back in the host Kermit session. Type:

    C-Kermit> SEND <filename>
    

Your file should transfer to the 3B2 at about 1200 bytes per second. Not blazingly fast, but tolerable.

Copying Data from the 3B2 to the Host Computer

This is really just the reverse procedure. You do exactly the same things, except on the 3B2 C-Kermit session, you type:

C-Kermit> SEND <filename>

And on the Host Kermit session, you type:

C-Kermit> RECEIVE

6.2. Using a CTC Tape Image

This method is quite easy to use, but unfortunately limited to files no larger than about 22MB in size, since that's the size of each blank tape.

The basic idea is to write a CPIO archive to a specific location on a blank tape image under Linux, and then in SVR3 to read the CPIO archive out of the raw tape device.

On the Simulated 3B2

  1. Format a blank tape using the sysadm tapemgmt feature of SVR3. Or, if you want a pre-canned blank tape image, you can download one here. (22 kB compressed)

On the Linux host

  1. Prepare a cpio archive of the files you wish to transfer to the emulated 3B2. In Linux, you must remember to pass the --format odc flag to build a compatible cpio archive, e.g.:

    $ find . -depth -print | cpio -ov --format odc > ../example.cpio
    
  2. Use dd to write the archive into the blank area of the tape. By passing the seek=31 flag, we skip the tape header and seek to the actual data area of the tape image.

    $ dd if=example.cpio of=ctc_xfer.tap bs=512 seek=31 conv=notrunc
    
  3. Finally, attach the CTC tape image under SIMH

    sim> set ctc enable
    sim> attach ctc ctc_xfer.tap
    

On the Simulated 3B2

Now we can restore from tape, just like you would on a real 3B2.

# ctccpio -idumvT /dev/rSA/ctape1

This will restore the contents of the tape archive to the current directory.

6.3. Using a Hard Disk image

This method is really a tremendous hack, but it's probably the fastest way to transfer very large that are too big to fit onto a CTC tape image. The basic concept is the same as the one used for CTC tapes, except you're writing to a blank area of a hard disk instead.

On the Linux Host

  1. Prepare a blank hard disk image with a valid low level format, partition table, and VTOC. If you need a pre-built image, one is available below. Download the file hd72_xfer.img.gz and uncompress it.
  2. Prepare a cpio archive of the files you wish to transfer to the emulated 3B2. In Linux, you must remember to pass the --format odc flag to build a compatible cpio archive, e.g.:

    $ find . -depth -print | cpio -ov --format odc > ../example.cpio
    
  3. Use dd to write the archive into the blank hard disk image. By passing the seek=810 flag, we skip into an unused area of the disk.

    $ dd if=example.cpio of=hd72_xfer.img bs=512 seek=810 conv=notrunc
    
  4. Finally, attach the disk image under SIMH (you must do this when the 3B2 is powered down!)

    sim> set idisk1 hd72
    sim> attach idisk1 hd72_xfer.img
    

On the Simulated 3B2

Now we reverse the process on the 3B2 by using dd and cpio to read from the raw emulated disk.

# dd if=/dev/rSA/disk2 skip=648 bs=512 | cpio -idv

(Note that we skip 648 blocks instead of 810. That is intentional, because the first cylinder is not mapped to the /dev/rSA/disk2 device.)

7. Using UNIX SVR3

If your only experience with UNIX-like systems is through modern Linux, you should be aware of a few things.

First, SVR3 is not loaded with fancy utilities like Linux. The base 3B2 installation doesn’t even come with man pages.

Second, you don't (by default) get a backspace character. That’s not a problem with the simulator, that’s really how SVR3.2 works. If you want to delete a character, you have to type the pound / hash symbol (#). And if you want to delete the whole line and start again, you have to press the at symbol (@).

7.1. Control Character Setup

You can change these default terminal control characters to something more familiar with the stty utility.

stty intr \^C erase \^? kill \^U

Some terminal emulators send CTRL-H to delete a character. On such a terminal, you can use:

stty erase \^H

To check the current values:

stty -a

7.2. Terminal Setup

If you want to use the vi editor in visual mode, you will need to define your TERM environment variable to something that SVR3.2 recognizes. It’s generally safe to set this to vt100.

TERM=vt100
export TERM

You can put this into your .profile file to set it automatically each time you log in.

7.3. Shutting Down

Don't forget to shut down cleanly by typing:

# shutdown -i0 -g0 -y