Git Product home page Git Product logo

freebee's Introduction

freebee

FreeBee - AT&T 3B1 emulator

FreeBee is an emulator for the AT&T 3B1. It's a work-in-progress, but currently works well enough to boot the operating system and to compile programs with the standard C compiler.

Maintained by

Phil Pemberton -- [email protected]

Limitations

Mac OS X support

There have historically been a few instability issues on the Mac OS X platform, related to the SDL libraries. I've not heard much about them.

Unfortunately I don't have a recent Mac, so I won't be able to reproduce or test issues which affect OS X versions later than High Sierra. Bugs will likely be left open until someone with a more recent system is able to look into them (unless you open a pull request with a fix!)

If you have an issue on OSX and have a Windows or Linux system, please try to reproduce the issue on there as it will be easier for me to test. Please list all the platforms you've tested on (and the result) in the issue.

In summary: all support is on a best-effort basis, but I cannot guarantee that bugs reported solely on Mac OS X will be fixed as I don't have the equipment to test with.

Memory mapper emulation inaccuracy

There is a workaround in the memory mapping emulation, which allows supervisor-mode writes to low memory. If this is disabled, the kernel will fail to boot with a PAGEIN or PAGEOUT panic.

If anyone can figure this out,

Things which are emulated...

  • Revision P5.1 motherboard with 68010 processor, WD2010 hard drive controller and P5.1 upgrade.
  • 720x348 pixel monochrome bitmapped graphics.
  • 4MB RAM (2MB on the motherboard, 2MB on expansion cards).
    • This is the maximum allowed by the memory mapper.
  • Keyboard and mouse.
  • WD2010 MFM Winchester hard disk controller.
    • Two separate drives.
    • Maximum 1400 cylinders (limited by the UNIX OS, see the UNIX PC FAQ, section 5.6).
    • Heads fixed at 8.
    • Sectors per track fixed at 17.
    • Fixed 512 bytes per sector.
    • Those numbers are the default configuration; see below for more information.
  • WD2797 floppy disk controller.
    • Double-sided, 512 bytes per sector, 10 sectors per track, any number of tracks.
  • Realtime clock.
    • Reading the RTC reads the date and time from the host.
    • Year is fixed at 1987 due to Y2K issues in the UNIX PC Kernel.
  • Serial port.
    • Linux only: file 'serial-pty' is symlinked to PTY that can be used to access tty000
    • Usage instructions: README.serial.md

Things which aren't emulated fully (or at all)

  • Printer port
  • Modem
    • You will get errors that '/dev/ph0 cannot be opened' and that there was a problem with the modem. Ignore these.

Build instructions

  • Install the libsdl2-dev package
  • Clone a copy of Freebee (remember to check out the submodules too)
    • git clone --recurse-submodules https://github.com/philpem/freebee
  • Build Freebee (run 'make')

Running Freebee

Initial Setup

  • Download the 3B1 ROMs from Bitsavers: link
  • Unzip the ROMs ZIP file and put the ROMs in a directory called roms:
    • Rename 14C 72-00616.bin to 14c.bin
    • Rename 15C 72-00617.bin to 15c.bin

Option 1: Use an existing drive image

  • Arnold Robbins created a drive image installed with all sorts of tools: here
  • David Gesswein created a drive image for the VCF Museum: here
  • Uncompress either of these images in the Freebee directory and rename the image to hd.img, or create a .freebee.toml file pointing to the image. (See the CONFIGURATION section of the man page.)

Option 2: Do a fresh install

  • Download the 3B1 Foundation disk set from Bitsavers: here
    • The disk images on unixpc.org don't work: the boot track is missing.
    • Use the replacement version of the 08_Foundation_Set_Ver_3.51.IMD image which is available here.
  • Create a hard drive image file:
    • Use the makehdimg program supplied in the tools directory to create an initial hd.img file with the number of cylinders, heads and sectors per track that you want. Limits: 1400 cylinders, 16 heads, 17 sectors per track.
    • When using the diagnostics disk to initialize the hard disk, select "Other" and supply the correct values that correspond to the numbers used with makehdimg.
    • Alternatively, you can use dd if=/dev/zero of=hd.img bs=512 count=$(expr 17 \* 8 \* 1024) to create a disk matching the compiled-in defaults. Initialize the disk using the "Miniscribe 64MB" (CHS 1024:8:17, 512 bytes per sector) choice.
    • The second hard drive file is optional. If present, it should be called hd2.img. You can copy an existing hd.img to hd2.img as a quick way to get a disk with a filesystem already on it. When Unix is up and running, use mount /dev/fp012 /mnt to mount the second drive. You may want to run fsck on it first, just to be safe.
  • You can also use the ICUS Enhanced Diagnostics disk. A bootable copy is available here. Uncompress it before using.
  • Install the operating system:
    • Follow the instructions in the 3B1 Software Installation Guide to install UNIX.
    • Copy 01_Diagnostic_Disk_Ver_3.51.IMD to floppy.img in the Freebee directory.
    • If you wish to increase the swap space size, do so with the diagnostics disk before installing the OS. See these instructions.
    • To change disks:
      • Press F11 to release the disk image.
      • Copy the next disk image to floppy.img in the Freebee directory.
      • Press F11 to load the disk image.
    • Instead of 08_Foundation_Set_Ver_3.51.IMD use 08_Foundation_Set_Ver_3.51_no_phinit.IMD from here. This will allow the emulated Unix PC to come all the way up to a login prompt after the installation.

Importing files

  • Files can be imported using the 3b1 msdos command which allows reading a 360k MS-DOS floppy image.
    • Use dosbox to copy files to a DOS disk image named floppy.img. This image must be in the same directory as the Freebee executable (or path specified in the .freebee.toml config file).
    • If the floppy.img file wasn't present on boot or was updated, hit F11 to load/unload the floppy image.
    • Run msdos from the 3b1 command prompt, grab the mouse cursor with F10 if you haven't already, then COPY files to the hard drive.
  • Another option is to use the s4tools here which allow you to export the file system image out of the disk image and import the fs image back. In particular, there is an updated sysv Linux kernel module which allows mounting the fs image as a usable filesystem under Linux.

Scaling the display

You can scale the display by setting scale factors in the .freebee.toml file. Scale values must be greater than zero and less than or equal to 45. This facility is useful on large displays.

Keyboard commands

  • F10 -- Grab/Release mouse cursor
  • F11 -- Load/Unload floppy disk image (floppy.img)
  • Alt-F12 -- Exit

3b1-specific key mappings

  • F1-F8 -- "soft keys" at bottom of screen
  • F9 -- SUSPD key (brings up list of windows)
  • Alt-Esc -- EXIT key
  • Alt-Backspace -- CANCL key
  • Page Up -- HELP key
  • Page Down -- PAGE key
  • Insert -- CMD key
  • Enter -- RETURN key
  • Alt-Enter -- ENTER key
  • Pause Break -- RESET BREAK key

Useful links

Other Notes

  • To make an MS-DOS disk under Linux (9 tracks per sector):

    dd if=/dev/zero of=dos.img bs=1k count=360
    /sbin/mkfs.fat dos.img
    sudo mount -o loop -t msdos dos.img /mnt
    ... copy files to /mnt ...
    sudo umount /mnt

  • To make a 10 track per sector disk image, just use count=400 in the dd command and then format the disk under Unix with iv and mkfs.

  • See this part of the FAQ on setting up multiple login windows.

freebee's People

Contributors

agentbooth avatar andreww591 avatar arnoldrobbins avatar low-power avatar philpem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

freebee's Issues

How, EXACTLY, do I access a DOS disk image?

Hi!

I saw the documentation talk of something called "discim", but I could not figure out how, EXACTLY, I can transfer files in and out of the emulator. As user "install", there is something called "Floppydisk" in a menu, and there is "MSDOS Disk Read" as a submenu, and I cannot get it to work...

Is this even the correct way to try? Or do I log in as root and somehow use the mount command? EDIT: I discovered the msdos command you mentioned, and ran it as root, but nothing seems to happen - it simply tells me there is, effectively, no floppy! I do not get how to use F11, it does nothing noticeable...

Thank you in advance for your kind help and for this awesome emulator!

SDL window size incorrect

This could be done with #7

if ((screen = SDL_SetVideoMode(720, 384, 8, SDL_SWSURFACE | SDL_ANYFORMAT)) == NULL) {

The 3B1 screen is 720x348, not 720x384. This puts a black border along the bottom of the screen.

If #7 happens, this should be 348+statusbarHeight.

UNIX 3.51m fails to boot, hangs on Disk Ctrlr message

The UNIX 3.51m kernel (from FixDisk 2) will not boot on FreeBee. The following messages are displayed:

Version 3.51m
Real memory      = 4194304
Available memory = 3846144
Main board is P5.1
Disk Ctrlr=?

Disk Ctrlr=?

Disk Ctrlr=?

The "Disk Ctrlr" message repeats endlessly and the machine never boots.

no SDL output on macOS

mac:/Users/tenox/Code> sdl-config --version
1.2.15
mac:/Users/tenox/Code> sdl2-config --version
2.0.12

built latest version from head, the emulator starts and you can see it reading the disk:

mac:/Users/tenox/Code/freebee> ./freebee                                                       
FreeBee: A Quick-and-Dirty AT&T 3B1 Emulator. Version 0.0. (git c88db4c), debug mode.
Copyright (C) 2010 P. A. Pemberton. All rights reserved.
Licensed under the Apache License Version 2.0.
Musashi M680x0 emulator engine developed by Karl Stenerud <[email protected]>

Set 720x348 at 32 bits-per-pixel mode

ERROR loading disc image 'discim'.
src/wd2010.c:81:wd2010_init(): WD2010 initialised, 1040 cylinders, 8 heads, 16 sectors per track
Disc image loaded.
unhandled write16, addr=0x00E50004, data=0x00000018
unhandled write16, addr=0x00E50006, data=0x00000018
unhandled write16, addr=0x00E50004, data=0x000000F0
unhandled write16, addr=0x00E50006, data=0x000000F0
KBD WR 00 => 0300
KBD WR 00 => 9500
unhandled write16, addr=0x00E44000, data=0x00008000
unhandled write16, addr=0x00E45000, data=0x00008000
unhandled write16, addr=0x00E60000, data=0x00000001
unhandled write16, addr=0x00E60000, data=0x00000000
unhandled write16, addr=0x00490000, data=0x00004000
unhandled write16, addr=0x00491000, data=0x00004000
unhandled write16, addr=0x00494000, data=0x00000000
unhandled write16, addr=0x00495000, data=0x00000000
unhandled write16, addr=0x00493000, data=0x00004000
unhandled write16, addr=0x00497000, data=0x00004000
unhandled write16, addr=0x004F0000, data=0x00000000
unhandled write08, addr=0x004B0400, data=0x00000000
unhandled write08, addr=0x004B0800, data=0x00000000
src/wd2010.c:358:wd2010_write_reg(): WD2010: READ SECTOR cmd=20 chs=0:0:0 nsectors=1
src/wd2010.c:393:wd2010_write_reg(): 	READ lba = 0
src/wd2010.c:399:wd2010_write_reg(): 	READ len=512, pos=0, ssz=512
src/wd2010.c:169:wd2010_read_data(): WD2010: read done
src/wd2010.c:358:wd2010_write_reg(): WD2010: READ SECTOR cmd=20 chs=0:0:1 nsectors=0
src/wd2010.c:393:wd2010_write_reg(): 	READ lba = 512
src/wd2010.c:399:wd2010_write_reg(): 	READ len=512, pos=0, ssz=512
src/wd2010.c:169:wd2010_read_data(): WD2010: read done

However in the SDL window there is nothing:

image

Thanks :)

Exiting with no mounted floppy disk causes segfault

If Freebee has not mounted a floppy disk (the file pointer is NULL), there will be a segfault at src/main.c:462 when Freebee exits:

src/wd2010.c:349:wd2010_write_reg(): WD2010: READ SECTOR cmd=20 chs=0:0:0 nsectors=1
src/wd2010.c:384:wd2010_write_reg(): 	READ lba = 0
src/wd2010.c:390:wd2010_write_reg(): 	READ len=512, pos=0, ssz=512

Thread 1 "freebee" received signal SIGSEGV, Segmentation fault.
_IO_new_fclose (fp=0x0) at iofclose.c:48
48	iofclose.c: No such file or directory.
(gdb) bt
#0  _IO_new_fclose (fp=0x0) at iofclose.c:48
#1  0x0000555555563d70 in main () at src/main.c:462
(gdb) bt f
#0  _IO_new_fclose (fp=0x0) at iofclose.c:48
        status = <optimised out>
#1  0x0000555555563d70 in main () at src/main.c:462
        i = <optimised out>
        screen = 0x55555597b890
        SYSTEM_CLOCK = 10000000
        TIMESLOT_FREQUENCY = 100
        MILLISECS_PER_TIMESLOT = 10
        CLOCKS_PER_60HZ = 166666
        NUM_CPU_TIMESLOTS = 500
        next_timeslot = <optimised out>
        clock_cycles = 101516
        tmp = <optimised out>
        exitEmu = <optimised out>
(gdb) 

Emulate serial port

The emulator currently doesn't support the UNIX PC's onboard serial port.

It would be useful to have this, perhaps terminating in a PTY.

please don't use sed in makefile

$ make
expr: syntax error
sed: 1: "s|@@compiler@@|clang: w ...": unescaped newline inside substitute pattern
make[1]: *** [versionheader] Error 1
make: *** [all] Error 2

replacing sed with gnu-sed

$ make
expr: syntax error
gsed: -e expression #6, char 69: unterminated `s' command
make[1]: *** [versionheader] Error 1
make: *** [all] Error 2

Running freebee help

I don't understand all this compiling and makefile stuff. How can I get the latest prebuilt version that will run on 32bit windows. (I should be able to install the OS by myself).

Emulate MODEM

The UNIX PC has an onboard 1200-baud Western Electric / AT&T modem chipset.

It would be useful to emulate this, perhaps as a PTY.

This lack of emulation is the cause of several bootup error messages:

  • /dev/ph0 can not be opened. Touch any key to continue.
  • Failed to open modem port. Error return= 19

Kernel panic when running gzip or cc from the 3.51 Development Set

From: Robert Masterson on Mon, May 12, 2014 at 10:18 PM

Also, UNIX crashes with a panic in the emulator when I run the precompiled gzip or the cc from the 3.51 Development set.
The input to either program does not matter--the crash always occurs as long as there is some input.
This behavior got me thinking that there may be an error in shared memory emulation. As you know, the 3b1 VM system has 512KB dedicated to shared memory, which some programs use, and some do not.
Is it possible that there is a bug in the memory system relating to the shared memory segment? (I am just guessing that cc and gzip make use of it, but something distinguishes these programs from those that do not cause a panic.)

Dismount failed errors while installing 3.51

During UNIX 3.51 installation, there are several benign "unmount failed" errors.

But Robert Masterson reported that these don't occur...

From: Robert Masterson on Mon, May 12, 2014 at 10:18 PM

1) I get no "dismount failed" errors when installing from the 3.51 Foundation set.
  • Re-test a build from around May 2014 and confirm whether this worked back then.
  • Is it a write protection issue? Image files marked read-only perhaps?
    • Are we correctly feeding write-protect back to UNIX via whatever hardware status registers we have?

Add configuration file support

Configuring the emulator currently requires editing hard-coded sections of code and recompiling. This is inflexible and annoying.

Freebee should use a configuration file to set up the emulator. This could be, for example, a YAML file. If YAML were used, Libcyaml could be used to parse it:

As a minimum, the following should should be configurable:

  • Amount of memory (base and expansion)
  • Hard disc geometry and filename (if raw binary file)
  • Floppy disc filename and optional geometry
    • Geometry only needed for raw binary files
    • Optional: add support for a 'floppy disc list' and next/prev buttons (e.g. altF11 next, shiftF11 prev) in the emulator interface. This would make installing UNIX easier.

Clean up macro usage

Macros are used extensively within the code, especially in the emulator interface (memory access). The way they're used rarely follows best practice, looks messy, and confuses the way the code works. Furthermore, they're large and hard to follow.

At the very least the access-check functions should be reimplemented as static inline functions -- other macros should be reviewed.

UNIX 3.51 hangs on second boot after install due to lack of modem emulation

UNIX 3.51 boots fine after installation. After shutting down and rebooting, however, the UNIX PC hangs on the "waiting" screen.

This is due to the modem port and UART not being emulated.

This lack of emulation also causes several error messages during installation:

  • /dev/ph0 can not be opened. Touch any key to continue.
  • Failed to open modem port. Error return= 19

Add ImageDisk floppy image read-write support

Freebee currently requires that floppy disk images be binary, in a fixed C/H/S geometry.

Many UNIX PC disk images (notably the ones on Bitsavers) are in Dave Dunfield's Imagedisk format. It would be useful if this format could be read and written without having to convert to binary.

An alternative would be a simple utility to convert between Imagedisk and a simpler uncompressed format which supported variable geometry and especially variations in sector size and count.

This would remove the need for running Imagedisk in a virtual machine to convert the IMD images to binary.

Unix 3.51m kernel panics on large disk

I have a large disk image (1400 cylinders x 16 heads x 17 sectors per track). I installed FIXDISK 2.0 and I get a kernel panic upon boot as shown in the attached screen shot.
kernel-panic

Finish P5.1 emulation - second hard disk

The P5.1 emulation is currently incomplete. Freebee can currently emulate a single large hard drive (up to 1400 cylinders, 16 heads, 16 sectors -- or 175MB) but not a pair of them.

Setting base_memory to 512 and extended_memory to 0 results in trouble booting

When configuring a system with only 512K RAM, I am usable to boot to login. This was tested using David Gesswein's VCF disk image with the 3.51m kernel. Upon startup it states 315392 available memory (from the 524288 total memory listed). When setting to 1024K RAM, the system boots fine.

The system attempts to load but asserts during "loading drivers" or "setting up screen" in the attempts I've made:
freebee: src/memory.c:1063: m68k_read_memory_8: Assertion 'address != 0xFFFF01' failed.
indicating Musashi m68ki_exception_bus_error() triggered the condition. Musashi says this occurs when a bus error occurs when we were already processing a bus error, address error, or reset, this is a catastrophic failure.

Perhaps the system is running out of memory and attempts to swap? The swap size for that hard drive image looks to be the default 5000k. (Though I don't know how to confirm the 5MB swap is being used.) In normal operation with 4MB RAM, I assume we never need to swap. Perhaps it's something related to memory handling and attempting to swap to hard drive? There is some interplay between different type of page table entries (PTEs) that I don't fully understand:
pte/htpe: MAP RAM (where we update the page status bits in mapAddr() )
mpte: pte's in RAM, used by the OS
fpte: pte's in disk

from sys/pte.h:
/*

  • Incore page table entry
  • There are two major kinds of pte's: those which have ever existed (and are
  • thus either now in core or on the swap device), and those which have
  • never existed, but which will be filled on demand at first reference.
  • There is a structure describing each. There is also an ancillary
  • structure used in page clustering.
    */

/* The format of a pte in the map /
struct pte
{
ushort pt_wp:1, /
write permission /
pt_acc:2, /
access status /
:3, /
non h/w flags /
pt_pfnum:10; /
core page frame number */
};

/* The format of a pte in memory (our RAM) /
struct mpte
{
ushort pg_ipte; /
index of hardware pte /
ushort pt_wp:1, /
write permission /
pg_acc:2, /
access control /
pg_fod:1, /
is fill on demand (=0) /
pg_swapm:1, /
have to write back to swap /
pg_pageo:1, /
page is being paged out /
pg_pfnum:10; /
core page frame number or 0 /
};
struct fpte
{
ushort pg_blkno; /
file system block number /
ushort pt_wp:1, /
write permission /
pg_acc:2, /
access control /
pg_fod:1, /
is fill on demand (=0) /
pg_swapm:1, /
have to write back to swap /
pg_pageo:1, /
page is being paged out /
pg_last:1, /
last data page /
pg_lastsec:2, /
disk sectors in the last data page*/
pg_fileno:7; /* file no for the page */
};

This issue can be worked around by setting base memory to 1024.

Smarter hard disk image support (header?)

The hard disk image is currently a raw binary file.

It may be useful to add a header to this file to store the disk geometry, or a more structured format. This would allow for cylinder, head and sector range checking in the WD2010 driver.

The format could be organised as a header, followed by a sequence of numbered tracks, each containing numbered sectors. These would be appended to the file when a FORMAT TRACK command was sent to the WD2010.

Optionally the hard disk image data could be compressed, a la MAME's CHD format. This could be on a track-wise or sector-wise scale. The disadvantage is that this would be more complex to read and write, and may require an "overlay" file to store deltas.

Add status line to main window

The main window should have a status line with e.g.:

  • Diagnostic LEDs
  • FDD mounted Y/N (click to unmount)
  • Floppy disk access indicator
  • Hard disk access indicator

Emulate printer port

Freebee currently doesn't emulate the printer port. This would be nice to have.

Emulate expansion cards

The 3B1 supports up to three S4BUS-interface expansion cards. Examples include the Ethernet, StarLAN and Combo Card.

Emulation support for S4BUS would allow emulation of these additional interfaces, and perhaps also a "host filesystem" driver or lightweight high-speed serial port.

Emulate VIDPAL expansion

The VIDPAL was an upgrade to the base 3B1 which sat between the 68010 CPU and the motherboard.

When the VIDPAL detected an access to video memory, it forced the CPU status bits to indicate a supervisor access. Effectively this bypasses memory protection for VRAM, allowing higher video RAM refresh rates.

This was used to great effect with a 3B1 GUI windowing system implementation.

While VIDPAL can be emulated with a software driver, emulating the hardware would provide a clear performance benefit to user code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.