Revive GEMDOS for lisa

Gemdos was known as atari ST operating system (to be precise, TOS is GEM + atari port of GEMDOS). This OS was primarily developped on Lisa and VME10 platform.


Caldera did buy parts of Digital research Inc and released old sources to public.


This hack aims to run gemdos and gem on lisa hardware.


One interesting archive is oemkit.zip

 

It's a kind of patch over gemdos build environment.

 

The interesting file is bootflop.bat:

 

 

REM THIS BATCH FILE CREATES A BOOTABLE 3.5 DISKETTE
REM IT IS ASSUMED THAT YOU HAVE ALREADY FORMATTED THE DISKETTE WITH FORMAT.PRG
REM IF YOU WISH TO ABORT, ENTER APPLE C KEYS
REM IF YOU WISH TO CONTINUE, ENTER THE ENTER KEY
PAUSE
COPY C:GEMDOSFI.SYS A:GEMDOSFI.SYS
COPY C:COMMAND.PRG A:COMMAND.PRG
PUTBOOT A: SFBOOT.ABS
REM TO EJECT THE DISKETTE, SIMULTANEOUSLY ENTER APPLE key & numeric pad ENTER KEY
REM THIS OPERATION IS COMPLETED

 

 

We clearly see here that a boot floppy is made of 3 "files" 

  • GEMDOSFI.SYS is the OS in a single file.
  • COMMAND.PRG is a textmode command interpreter in a GEMDOS executable format, this binary run as is on atari ST hardware
  • SFBOOT.ABS is the boot sector

 

The creation of boot disc is the following procedure:

  • format a GEMDOS disc
  • copy OS file (GEMDOSFI.SYS)
  • copy command interpreter command.prg
  • install boot sector
  • link OS file to bootsector (a bootloader cannot read a filesystem, so some kind of sector table must be written in the bootsector itself or in the next sectors)
  • make the bootsector bootable (ie a special TAG value for apple lisa).

The inline command PUTBOOT (inlined in command.prg) shouldl do the last 3 steps of this procedure...

Find PUTBOOT code...

We find in source new_cmd.c

 

else if (xncmps(8,s,"PUTBOOT"))  
{          
if (*nonStdIn) dspCL (&argv[0]);
ucase (p);
drv = *p - 'A';  
fd = xopen(argv[2], 0);
xread(fd,540L,buf); 
xclose(fd);   
super();      
rwabs(1,&buf[28],1,0,drv);  
user();     
dspMsg(5);
}          





So PUTBOOT is just a raw write of 512 bytes at offset 28 of the file in argument.

That is confirmed in the binary dump of the resulting disc image.

 

Disc geometry

We need to find disk geometry for lisa gemdos discs

Here we are in file main.c of oemkit.zip

We find definitions for Sony drive and 2 profiles (5Mb only).

/* drive C is profile, A and B are 5 1/4 twiggys */

/* ... the way God intended disks to be */


BPB bpbx[] = {  {  512, 2, 1024,  5,  3,  4, 12,  390, 0 },

{  512, 2, 1024,  5,  3,  4, 12,  390, 0 },

  {  512, 2, 1024, 32, 12, 13, 57, 4000, 2 } , /* fixed */

  {  512, 2, 1024, 32, 12, 13, 57, 4000, 2 } } ; /* fixed */


/*

 *                      recsiz       rootrecs    datrec#    flags(16-bit fat)

 *                          clsiz       fatrecs      numclust (fixed disk)

 *                              clsizb       fatrec#        

 * Atari ROM Disk

 * BPB bpbx[1] = {  512, 2, 1024,  2,  1,  1,  4,  254,   0 } ;

 * IBM 5 1/4 DSDD

 * BPB bpbx[1] = {  512, 2, 1024,  7,  2,  3, 12,  350,   0 } ;

 * Lisa profile for GEMDOS demo  old:     12  13  57  4000    0

 * BPB bpbx[1] = {  512, 2, 1024, 32, 20, 21, 74, 5000,   1 } ;

 * Lisa twiggys

 * BPB bpbx[1] = {  512, 2, 1024, 15,  3,  4, 22,  840,   0 } ;

 * Lisa sony drive (SS)

 * BPB bpbx[1] = {  512, 2, 1024,  5,  3,  4, 12,  390,   0 } ;

 * Compaq hard disk C:

 * BPB bpbx[1] = {  512, 8, 4096, 32,  7,  8, 47, 2119,   0 } ;

 * 8 inch SSSD       *7,*13 on some disks 

 * BPB bpbx[1] = {  128, 4,  512, 17,  6, 10, 16,  492,   0 } ;

 * 8 inch DSDD

 * BPB bpbx[1] = { 1024, 1, 1024, 6,   2,  3,  5, 1221,   0 } ;

 */

Build a boot disk

For now, an emulator will be used. Disc must be a disc copy 4.2 image.

booting (bootsector)... 

 

GEMDOS filesystem is FAT12 with minor variations.

We derive a build image tool from different sources (tool will be published soon :) ). Sources are from:

  • IDLE : my lisa emulator
  • ray's lisaFS tool (an early version)
  • a FAT12 module
  • GEMDOS for lisa itself (traduction tables block -> track/head)

Result is a disccopy 4.2 image with a lisa FAT : that you may download here :) (update : now running)

Now the result (in "intergalactic" exclusivity ;) )

You may now start gemdos in emulators (both IDLE and lisaem). Not tested yet on real hardware but... It'll work...

Now the tool itself

This tool uses a non free FAT12 implementation that is part of miniC by Dave Dunfield (www.dunfield.com). Since this hack is open source and non commercial, I suppose it does not hurt the conditions of use...

Download the tool and files

Warning:

Source (ie FAT12 component) is strictly x86 and will not compile elsewhere (maps C structure with short little endian integers...).

To modify the disc files:

in main.c

 

  write_fs("GEMDOSFI.SYS","GEMDOSFI.SYS"); // this one must be the first in disc since the bootloader (the bootloader does not read the FAT but a does a raw read of first N allocatable sectors)

    

  write_fs("COMMAND.PRG","COMMAND.PRG");  

 

  write_fs("GEMVDI.PRG","GEMVDI.PRG");  

 

  write_fs("GEM.PRG","GEM.PRG");  

  write_fs("GEM.RSC","GEM.RSC");  

 

  

  write_fs("ASSIGN.SYS","ASSIGN.SYS");  

  write_fs("LISA25.SYS","LISA25.SYS");  

  write_fs("META.SYS","META.SYS");  

  write_fs("IBMHSS10.FNT","IBMHSS10.FNT");  

...