Saturday, February 25, 2012

PIA = Pain In the Ass

I swear, it's the little things that trip you up.  I fought two battles today with the continuing effort to get the NitrOS-9 port more smoothly working with the Atari XEGS.  The first was getting the SIO port to work reliably.  The second was getting the Atari into all-RAM mode.  Both were necessary to bring the project forward.

Some background: booting NitrOS-9 from ROM is fine for development, but to make Liber809 convenient as a product, people don't want to burn ROMs every time they want to reconfigure the OS (not everybody has a ROM burner).  The ideal situation is to have a bootstrap ROM installed in the ROM socket of the Atari.  The code in that bootstrap ROM would pull in additional code from some external source (like a disk drive).  The ROM code wouldn't change, and the malleable code on the disk would be easy to update, etc. 

Well, the obvious solution these days is a Mac, Linux or PC based server that acts as a virtual disk server... like DriveWire.  It turns out that the Atari guys have their own SIO protocol and server-side software, but since I waned to turn out something quick, and being more familiar with DriveWire, I decided to start with that.

So the first battle was to understand and tame the SIO.  POKEY, which is one of the chips on the Atari, handles serial communications and has an internal shift register so all the software needs to do is write a byte and read a byte, etc.  But it's a little tricky, and I learned that.  It was an exercise in frustration trying to get reliable communication to the DriveWire 4 server at 38,400 bps, but after studying some example 6502 code and doing some experimentation, I finally got something that worked.  So now my boot ROM is happily pulling sectors off of DriveWire server.  Sloopy (a guy on the Atari forums) was kind enough to drop an SIO to USB adapter in the mail to me, which was critical in getting this to work.  Thanks Sloopy (not Sloppy!)

Now for the second battle.  A critical component in getting the OS loaded is to tell ROM to get the hell out of the way at the right time.  This is called "all-RAM" mode, and the Atari is capable of doing it.  However, for the life of me I could not get it to work.  I tickled bits, tried standing on my head, etc.  But nothing worked.  The helpful guys on the Atari forums gave me some hints and clues, and while working through everything, we came to the realization that the PIA needed to be initialized.  After more experimentation, I was finally able to get all-RAM mode working, albeit with a different value than what the documentation expects to be placed into the PIA's port register.  That's another battle for another time....

So the bottom line is that NitrOS-9 on the Atari XEGS is now booting from the DriveWire 4 server running on the Mac.  This is *BIG* because it gives users an easy way to introduce code into the system. It also further proves out that the Liber809 design is continuing to perform well.

No comments:

Post a Comment