[comp.sys.atari.st] AHDI

daniel@pkmab.se (Daniel Deimert) (06/11/89)

Talking about AHDI - what does it do exactly? It installs some kind of
driver, but what does that driver consist of. Is it possible for me to
write my own driver?
 By the way, why isn't there a way to boot up a TOS.IMG file from the
harddisk? Or is there? It would be nice having such a facility in the
new TOS 1.4 for future diskbased releases or rather using the old
versions (ie "mushroom-tos").  It would have been nice having this
option in the Mega TOS since you could have released a TOS version on
disk for those who cannot upgrade their ROMs in a while for some reason. 
I do think the developers would have been happy, too. 

Is there any particular problem with this?

 - daniel

  Daniel Deimert	   /  /    Internet: daniel@pkmab.se
  Fridstavaegen 4	  /  /     UUCP: ...{uunet,mcvax}!sunic.sunet.se!
  S-715 94  Odensbacken  /  /            kullmar!pkmab!daniel
  SWEDEN		/  /	   Phone: +46-19-52037, +46-19-111441 (BBS)

hcj@lzaz.ATT.COM (HC Johnson) (06/13/89)

In article <1257@pkmab.se>, daniel@pkmab.se (Daniel Deimert) writes:
> 
> Talking about AHDI - what does it do exactly? It installs some kind of
> driver, but what does that driver consist of. Is it possible for me to
> write my own driver?

AHDI (generic) is not a mystical program.
It is a Terminate-Stay-Resident program that when loaded does
these things:
a.	Attempt to read from each disk on the system.
b. 	For each partition labeled GEM, store its starting sector (and size).
c.	TOS does all disk (floppy and hard) io thru low memory vectors 
	(address) called hdv_rw, hdv_media, hdv_bpb. At boot time, these
	addresses are in the kernel, floppy disk handler.
d.	AHDI substitutes its own address for the kernel ones at these location
	(and remembers the old ones).
e. 	TOS references a drive as 0-15.  0 and 1 are floppies, so AHDI passes
	these calls to the saved vector addresses.
	2-15 may be hard drives, and if a starting sector, and drive address
	are saved for the number referenced, then it will do the disk operation.

f. 	note that if a ram disk is added, it does the same thing in substituting
	its addresses, so first its called (last one first), then passes
	control to (presumedly) AHDI, which will do the work, or pass control
	to the floppy driver in the kernel.

When AHDI scans for active disk drives it can do several things.
Atari Brand:
	The Atari host adapter is a little sick and will not indicate
whether drive 1 is present.  It does OK on drive 0.  SO, Atari's AHDI program
only tests for drive 0 on each SCSI address from 0-7.  As soon as it finds
no drive, it stops looking, and the only drives letters that can be accessed
are those partitions it found.

BMS/ICD/SUPRA:
	These allow 2 or more drives on each controller.
The Adaptec 400x series only support 2 drives.  Each drive is tested on each
controller until a drive 0 is not found.  

Howard C. Johnson
ATT Bell Labs
att!lzaz!hcj
hcj@lzaz.att.com

daniel@pkmab.se (Daniel Deimert) (06/14/89)

In article <627@lzaz.ATT.COM> hcj@lzaz.ATT.COM (HC Johnson) writes:
>AHDI (generic) is not a mystical program.
>It is a Terminate-Stay-Resident program that when loaded does

Thanks for that description.  And the "magical" autobooting program for
the atari harddisk, then? (I'm afraid I can't spell it right...)
 Is it just a normal program too, or is it some kind of IMG-file? How
does the TOS load it, and when? Is it possible to write an own version?
(Yes, of course, but without scratching my head for years!?)

  Daniel Deimert	   /  /    Internet: daniel@pkmab.se
  Fridstav. 4		  /  /     UUCP: ...{uunet,mcvax}!sunic.sunet.se!
  S-715 94  Odensbacken  /  /            kullmar!pkmab!daniel
  SWEDEN		/  /	   Phone: +46-19-52037, +46-19-111441 (BBS)

hcj@lzaz.ATT.COM (HC Johnson) (06/15/89)

In article <1268@pkmab.se>, daniel@pkmab.se (Daniel Deimert) writes:
> In article <627@lzaz.ATT.COM> hcj@lzaz.ATT.COM (HC Johnson) writes:
> >AHDI (generic) is not a mystical program.
> >It is a Terminate-Stay-Resident program that when loaded does
> 
> Thanks for that description.  And the "magical" autobooting program for
> the atari harddisk, then? (I'm afraid I can't spell it right...)
>  Is it just a normal program too, or is it some kind of IMG-file? How
> does the TOS load it, and when? Is it possible to write an own version?
> (Yes, of course, but without scratching my head for years!?)

This is an addenda to my previously posted  information on partitioning.
BOOTING

Finally a few words about booting from the hard disk.
There are two steps when TOS boots.

First, floppy disk A: is checked for a valid boot block.  If it has one
the loaded sector is executed as a program.  A 'rts' returns to TOS, so that
it can continue to phase 2.

Secondly, each SCSI device 0 thru 7 has logical unit 0 tested for a valid
boot block.  Note that SCSI controllers with more than one disk must have the
boot on unit 0.  Each device with a valid boot is executed. A 'rts' returns
to TOS, so that it can continue. (The Autobooters I've seen cause this polling
to be terminated.)

There are two schemes for having the disk load the official hard disk driver
from the boot code.

HDB from Atari, and GEMBOOT (public domain) put sufficient code in sector 0
of the hard disk to load the driver from the boot disk.  HDB renames ahdi.prg
to be driver.sys just to make this look mysterious.

Supra and ICD use extended partitions which removes 96 bytes from boot area
on sector 0.  In order to load the driver they have to read in an
additional sector of boot code.  This is stored in the boot block of any 
of the first four partition on the drive.  The first partition is usual,
but the first four partitions are tested looking for a bootable one.
This permits, for example:
	Set up partition 0 (drive C:) to boot MS/DOS using PC-Ditto;
	Set up partition 1 (drive D:) to boot TOS;
	Set up partition 2 (pseudo drive E:) to boot MINIX.
	Only one of these is marked 'active' in the partition table and
	it is the only one read in and executed.
Supra also signals TOS to stop looking for bootable drives after it runs.

Image.SYS:
	These files are just the AHDI program, renamed and given non
listing attributes.  (Use MWC ls -al *.sys to display them).

Howard C. Johnson
ATT Bell Labs
att!lzaz!hcj
hcj@lzaz.att.com

daniel@pkmab.se (Daniel Deimert) (07/22/89)

In article <631@lzaz.ATT.COM> hcj@lzaz.ATT.COM (HC Johnson) writes:
>> >AHDI (generic) is not a mystical program.
>> >It is a Terminate-Stay-Resident program that when loaded does
>> 
>>  Is it just a normal program too, or is it some kind of IMG-file? How
>
>HDB from Atari, and GEMBOOT (public domain) put sufficient code in sector 0
>of the hard disk to load the driver from the boot disk.  HDB renames ahdi.prg
>to be driver.sys just to make this look mysterious.

I have no HDB.  The program I've got on my "SH boot disk" is called
HINSTALL.  There are two datafiles as well, 204ROOT.IMG and 204BOOT.IMG.
I assume these are being copied on the bootblock? They are both of
sector-lenght (512 bytes). -BOOT- probably fits into the bootblock (seems
logical to me :-) but where is -ROOT- copied to?
The SYS-file on the harddisk is named "SH204DVR.SYS".

It is then possible for me to replace the .SYS-file with my own driver then?
It might maybe even do the trick with loading the TOS image-files?
Maybe one could do a boot-block which loads in, lets say about 10 sectors
of data. These sectors contains code to load the TOS and the AHDI. Maybe
even a resident virusdetector or something similar?
 A small problem:  How do I load the TOS?  Does it have to be loaded
BEFORE the AHDI and/or other code or can I just load it & start it?
[ I can jump right into the TOS-start adress, can't I? Allan?! ]

Why not load the driver directly in the boot-block? Any reason, besides
it is to big? :-)

  Daniel Deimert	   /  /    Internet: daniel@pkmab.se
  Fridstav. 4		  /  /     UUCP: ...{uunet,mcvax}!sunic.sunet.se!
  S-715 94  Odensbacken  /  /            kullmar!pkmab!daniel
  SWEDEN		/  /	   Phone: +46-19-52037, +46-19-111441 (BBS)