Apple II IDE/ATA interface

Stéphane Guillard - stephane.guillard@steria.com

 

1 - Introduction

The Apple II is one of the finest personal computers ever made, if not the finest. I love it, and even if one of mine is something like 15 years old, I still make hardware and software projects for it (I have a basic IIe, an enhanced IIe, a IIc w/384k, a ROM1 IIgs and a ROM3 IIgs).

I felt it lacked a hard disk, and that it would be fun to make my own hardware adapter and software, thus I designed an easy to build hardware interface. At present time, I have :

These routines are currently under development, at various stages of completion.

This project is (to my knowledge) unique and different from other existing Apple II HDD interfaces by the following aspects :

2 - Theory

The basics are :

Here are the interface (in slot 7) and HDD (on top of power supply, w/ insulating plastic shield), in my enhanced IIe :

Here are detailed pictures of interface and HDD, from both above and below :

 

3 - Hardware

Note : all pictures below may not be very readable on your setup, but if you save them and view them separately it should be OK.

The idea behind the 2 latches is to operate them asynchronously :

The following picture illustrates this :

The hardware schematics lie in two parts :

Please note that since the decoding logic is activated by the Device Select line from the Apple II slot, the interface is mapped as 16 bytes into the Apple address space.

In my setup, I put the interface in slot 7, thus addresses are in the C0F0 .. C0FF range.

The +5V and +12V DC power supply voltages for the IDE peripherals can be taken from the Apple II bus, but it is not really recommended, due to current limitations of the Apple II power supply. This is especially true if your Apple II is loaded with boards, like mine J

Don't make wiring too long. Add decoupling capacitors (100 nF) between +5VDC and GND on each chip.

All recommended pull-ups and pull-downs in the ATA specs are included in this design. It can handle 2 devices (master & slave), and supports cable select (then use a cable select-compatible IDE cable).

Schematics mention HCT class logic chips, but any (reasonably fast) kind will suit. My prototype is based on recycled chips coming from old boards.

On the photo of my prototype, there is a 20 pin DIL empty chip holder, it was intended for spare use but not used. Total chip count is 7.

4 - Software, basics

From a low level software point of view, the IDE registers map into the board address space this way :

Then I have written (Procode 65C02 assembly) a low level set of routines which are able to initialize the master IDE device, inquiry it and print info, analyze its MBR and find the partitions, and tell the 4 partition information. The code is commented, thus I won't go in explanations within this document. Here is its output with my drive (actual Apple II screen capture) :

From this base, and with the Master Boot Record and FAT structure definition, I have made an Excel file which helps calculating the position of various important sectors (MBR, FAT, 2nd FAT, First Root Dir Block, First Data Block) on the disk from its geometry, and gives cylinder / head / sector numbers, like the following for my hard drive and its only 1 FAT16 partition :

In the Excel file, all values in WHITE cells can be changed according to your hard drive. MBR should ALWAYS be at CHS 0 0 1.

The small BASIC listing included is a simple sector browser based on the assembly routines mentioned above, which will ask for a C H S location, read the 512 byte sector from the drive and display it in ASCII and HEX form. This simple program, which prompts for CHS, stores them in RAM, calls read sector routine and dump sector routine, gives the following output from my drive (3 actual Apple II screen captures) :

If you look at the third dumped sector (first block of the root directory of the first partition), you will recognize well-known files J

All screen captures made through a serial cable using an Apple II super serial card and HyperTerminal on the PC.

5 - Operating system software (OSS)

Introduction

From the experience collected with the above prototype software, I went on with the idea of writing a multi layer operating environment (OSS) for the HDD :

Each layer runs on top of the previous, except 5th runs directly on top of 3rd.

The idea is to distribute the OSS code as :

Development environment

Experiencing assembly coding with the prototype software has proved to be very inefficient (even if it is the best path to small and fast code), so in order to develop all this quickly, I decided to code all in C, then when everything is running, convert at least layers 1 to 4 back to assembly.

Thus I downloaded the CC65 6502 C compiler package from http://www.cc65.org (thanks Ullrich Von Bassewitz), and integrated it into Microsoft Visual C++ 6. Thus I can edit code in MSVC, compile it using CC65 (configured as an external make tool), edit errors directly in MSVC thanks to CC65 printing its errors in an MSVC style, and when all is OK, wrap the binary into an Apple II bin file (which consists in adding 2 address bytes and 2 size bytes at the beginning) using a small too lI made for this purpose.

Then the code is downloaded to floppy (DOS3.3, but works as well under ProDOS) on the Apple II using HyperTerminal on the PC and Kermit385 on the Apple II (Apple Super Serial Card set to 19.200 bauds and hardware handshaking).

Downloads

Here you can find the source and binaries for the current snapshot of the OSS.

6 - Limitations and future

7 - Version history

Version

Updates

0.0.1 - May-02-2001

First public delivery.

0.0.2 - May-03-2001

Only small adjustments over prev. Version.

0.0.3 - May 25-2001

Removed bug in ASM source : print A as 2 hex digits is $FDDA, not $FDE3.

Added first run of C source.

0.0.4 - June 17-2001

Fixed calculation in Excel file.

Completed POSIX API

Full working interactive sampler

7 - Thanks to

Legalese

I hope no one will find a legal issue in all this stuff, as its only purpose is have fun with open source hardware and software, experiment and share, and bring life back into an ancient but lovely computer.

" The author of this project can not be pursued in any case …"

" Use at your own risk …"

" Make backups … "

" Please if you propagate this project, do so using the original archives …"

" Send me back your enhancement ideas and source code …"

" Have fun …"