RamDisk and ATARI-ST Disk IO

GFA, ASM, STOS, ...

Moderators: simonsunnyboy, exxos, Mug UK, Zorro 2, Moderator Team

User avatar
leonard
Moderator
Moderator
Posts: 640
Joined: Thu May 23, 2002 10:48 pm
Contact:

RamDisk and ATARI-ST Disk IO

Postby leonard » Mon Aug 01, 2005 1:48 pm

Hi,

I'm looking forward good documentation about disk IO atari routines in order to write RAMDISK or Disk Encryption code. For exemple, what's the documentation of the structure located at $472.w ?

If anyone had URL on good document, or any reseident ramdisk source code or similar, I'm interested !
Leonard/OXYGENE.

User avatar
Mug UK
Administrator
Administrator
Posts: 11148
Joined: Thu Apr 29, 2004 7:16 pm
Location: Stockport (UK)
Contact:

Postby Mug UK » Mon Aug 01, 2005 2:00 pm

If you managed to download one of the Floppyshop CDs when the torrents were available, there's plenty of assembly source code for RAMdisks.

http://www.mikemee.plus.com/atari/tools/1parter.zip

The 1parter program was a tool which did a trap #1 re-route to load game files from a RAMdisk created by yourself .. maybe a quick bit of reverse engineering?
My main site: http://www.mug-uk.co.uk - slowly digging up the bits from my past (and re-working a few): Atari ST, Sega 8-bit (game hacks) and NDS (Music ripping guide).

I develop a free Word (for Windows) add-in that's available for Word 2007 upwards. It's a fix-it toolbox that will allow power Word users to fix document errors. You can find it at: http://www.mikestoolbox.co.uk

ijor
Hardware Guru
Hardware Guru
Posts: 2965
Joined: Sat May 29, 2004 7:52 pm
Contact:

Postby ijor » Mon Aug 01, 2005 2:04 pm

Hi Leonard,

These are vectors, not structures or pointers to structures. They are used by BIOS to access drives (floppies, ramdisks, hard disk, etc).

Drivers hook those vectors for installing ramdisk, harddisk, etc. They replace the vectors, and when they are called they check the drive number. And they then chain to the previous vector or not.

I guess you have Abacus ST internals. Look at the default vectors installed by the ROM if you want to see all the details (let me check ... $FC0DE6 is the default vector for $472). Note that the default vectors in ROM don't chain for other drivers as they are the last in the chain.

User avatar
leonard
Moderator
Moderator
Posts: 640
Joined: Thu May 23, 2002 10:48 pm
Contact:

Postby leonard » Mon Aug 01, 2005 2:57 pm

These are vectors, not structures or pointers to structures


Yes that's what I though at first, because I reminds writing some IO wrapper stuff like that (using $476.w). But in the R.AL crypter bootsector I find that:

move.l $472.w,a0 ; (which is a vector on a 68000 routine, I agree)
move.l $22(a0),a1 ; I don't know what A1 is !! (+$22 in the code ??)

On the other hand, I'm looking forward details about parameters located in stack when these vectors are called ($472, $476 etc.)

I don't have any book about ATARI (exept an old french one), and nothing about these system stuff. Anyone has document about all these ROM pointers and structures ?
Leonard/OXYGENE.

ijor
Hardware Guru
Hardware Guru
Posts: 2965
Joined: Sat May 29, 2004 7:52 pm
Contact:

Postby ijor » Mon Aug 01, 2005 3:20 pm

leonard wrote:But in the R.AL crypter bootsector I find that:

move.l $472.w,a0 ; (which is a vector on a 68000 routine, I agree)
move.l $22(a0),a1 ; I don't know what A1 is !! (+$22 in the code ??)


Yes, it's fetching a long word from code. Not sure exactly why it does or what is fetching there. I would guess that the crypter installs its own vector and driver. Then it is fetching some pointer from the installed driver.

There is nothing specific at +$22. It could be anything depending on the driver. But if it is your own driver, then you know exactly what is there. :wink:

I don't have any book about ATARI (exept an old french one)


Can't believe you 8O

On the other hand, I'm looking forward details about parameters located in stack when these vectors are called ($472, $476 etc.)


There are some references on the net. Others probably know better than me. The official ATARI documentation used to be in PDF format at atarimuseum, but it is not there anymore. Might be somewhere else.

The parameters for the vectors are the same than for the corresponding BIOS calls. When BIOS (trap #13) is called it just jumps to the content of the vector. So if you have any BIOS documentation that would be good enough.

User avatar
Mug UK
Administrator
Administrator
Posts: 11148
Joined: Thu Apr 29, 2004 7:16 pm
Location: Stockport (UK)
Contact:

Postby Mug UK » Mon Aug 01, 2005 3:28 pm

There's a few bits and pieces on my site .. however, since it's still waiting for the backup to be restored due to it being hacked, here's a link to the files themselves.

http://www.mikemee.plus.com/atari/docs/

st_docs and st_intern are probably the ones you'll want the most.
My main site: http://www.mug-uk.co.uk - slowly digging up the bits from my past (and re-working a few): Atari ST, Sega 8-bit (game hacks) and NDS (Music ripping guide).

I develop a free Word (for Windows) add-in that's available for Word 2007 upwards. It's a fix-it toolbox that will allow power Word users to fix document errors. You can find it at: http://www.mikestoolbox.co.uk

User avatar
leonard
Moderator
Moderator
Posts: 640
Joined: Thu May 23, 2002 10:48 pm
Contact:

Postby leonard » Mon Aug 01, 2005 6:32 pm

Can't believe you


Shame on me but I learned more about atari by looking other people code under debugger than reading books :-) I have "Le livre du developpeur", wich is a good book with hardware register list. But there is nothing about TOS stuff as $472, $476 (nothing in details).

There is nothing specific at +$22. It could be anything depending on the driver.


You're right. I just check it with TOS 1.00 I use under SainT, and +$22 points to an adress of the instruction:

adda.l #$4dce,a5

+$22 points on 4dce ! (wich is an internal buffer for disk IO I guess)

What an hardcode !!! It seems that R.Al crypter may not work with STE TOS.

Did anyone have document or source code about a "clean" way to do ramdisk or stuff like that ? (I "google" it but I don't find anything interesting)
Leonard/OXYGENE.

User avatar
Mug UK
Administrator
Administrator
Posts: 11148
Joined: Thu Apr 29, 2004 7:16 pm
Location: Stockport (UK)
Contact:

Postby Mug UK » Mon Aug 01, 2005 9:20 pm

In the old days of GFA BASIC, I would use the LPEEK(LPEEK($472)) to get the proper address of the routine at the address .. if it was pointing (via an offset) to a known piece of virus code then you could say your machine was infected.

e.g.

Code: Select all

addr_to_test=lpeek(lpeek(&H472)
if (addr_to_test+&H12)=&H6012 Then
   msgbox "You're infected with xyz"
end if
My main site: http://www.mug-uk.co.uk - slowly digging up the bits from my past (and re-working a few): Atari ST, Sega 8-bit (game hacks) and NDS (Music ripping guide).

I develop a free Word (for Windows) add-in that's available for Word 2007 upwards. It's a fix-it toolbox that will allow power Word users to fix document errors. You can find it at: http://www.mikestoolbox.co.uk

User avatar
leonard
Moderator
Moderator
Posts: 640
Joined: Thu May 23, 2002 10:48 pm
Contact:

Postby leonard » Mon Aug 01, 2005 10:35 pm

if (addr_to_test+&H12)=&H6012 Then


this is completly specific code. What I really need is just a documentation about what's the exact use of these threee vectors (472,476,47a), how TOS use "media change" callback, etc...
And, if possible, the source code of a working RAMDISK.

Does anyone in that forum has such doc or source code ?
Leonard/OXYGENE.

ijor
Hardware Guru
Hardware Guru
Posts: 2965
Joined: Sat May 29, 2004 7:52 pm
Contact:

Postby ijor » Tue Aug 02, 2005 1:36 am

Hi Leonard,

I have all the info you need, but unfortunately only in hardcopy not in electronic form.

There are several references, but what you want is the official Atari BIOS documentation: "A Hitchhiker's Guide to the BIOS". As I said it used to be online at atarimuseum, but it isn't there anymore. I should have that PDF in my backups. Will try to find it. I might have a Ramdisk source as well, but that will be harder to find because I have no idea about a specific filename or archive.

Searching the net I found this:

Hitch Hiker's Guide to the Bios Pt 1,2 3 SD019 DOC Instructions
(SD = Sewer Doc Disk)

I don't know where you can donwload the Sewer disks, but I'm sure somebody here will know. Alternatively look for the Devpac documentation which I belive it's online. It also has BIOS documentation.

Anyway, the three vectors are called for BIOS functions:

$476 = 4) rwabs
$472 = 7) getbpb
$47E = 9) mediach

That is, when an application (or GEMDOS) issue a trap #13 with, say, function #4. Then BIOS will jump to the vector in $476. So the parameters are exactly the same as for those bios calls.

A hard or ram disk driver hooks the 3 vectors, and store the old vector in its internal memory. When it is called by BIOS it checks the drive number. If the driver # belong to the driver then it process the call, otherwise it chains to the old vector.

If you can't find that Sewer doc let me know, in the worst case I'll type the parameters for those BIOS calls. Not big deal.

User avatar
Mug UK
Administrator
Administrator
Posts: 11148
Joined: Thu Apr 29, 2004 7:16 pm
Location: Stockport (UK)
Contact:

Postby Mug UK » Tue Aug 02, 2005 5:58 am

I'll upload a few examples later on today when I get into work ... taking my Floppyshop CDs in to save me packing them away when I move house.


*edit .. as promised, here's one of many I've found but the first with 68000 source code.


** 2nd edit .. another one found, this one is reset-proof.
You do not have the required permissions to view the files attached to this post.
My main site: http://www.mug-uk.co.uk - slowly digging up the bits from my past (and re-working a few): Atari ST, Sega 8-bit (game hacks) and NDS (Music ripping guide).

I develop a free Word (for Windows) add-in that's available for Word 2007 upwards. It's a fix-it toolbox that will allow power Word users to fix document errors. You can find it at: http://www.mikestoolbox.co.uk

User avatar
frost
Captain Atari
Captain Atari
Posts: 346
Joined: Sun Dec 01, 2002 2:50 am
Location: Limoges
Contact:

Postby frost » Tue Aug 02, 2005 11:15 am

The book "Le livre du lecteur de disquette et disques durs" may help you, but this one is hard to find :?
GT Turbo lend me a copy, I may find some interesting pages if you want.

User avatar
leonard
Moderator
Moderator
Posts: 640
Joined: Thu May 23, 2002 10:48 pm
Contact:

Postby leonard » Wed Aug 03, 2005 4:37 pm

thanks for your help.

Now I want to know another stuff: a diskcrypter have to know if a poarticular disk is inserted. R.AL check this by looking "AL" in the first sector, but it look this in memory, at a hardcoded adress (+$22 stuff).
Does anyone know a clean way to get a "disk signature" in the callback $476 ? (without read the bootsector each time ?)
RAMDisk application does not need to know such information, so ramdisk source code can't help...

any idea ?
Leonard/OXYGENE.

User avatar
leonard
Moderator
Moderator
Posts: 640
Joined: Thu May 23, 2002 10:48 pm
Contact:

Postby leonard » Wed Aug 03, 2005 9:13 pm

Maybe it's more easy with the source code. I commented a bit, there is two points where I really don't find any info on documentation.

I attached the disassembled version of diskio routines.
You do not have the required permissions to view the files attached to this post.
Leonard/OXYGENE.

ijor
Hardware Guru
Hardware Guru
Posts: 2965
Joined: Sat May 29, 2004 7:52 pm
Contact:

Postby ijor » Thu Aug 04, 2005 1:26 am

Hi Leonard,

It is using undocumented values. However, whoever wrote that program wasn't so silly as it might seems. As a matter of fact, and despite using undocumented TOS aspects, it seems the program will work fine in any TOS version ... as long as it's executed before any ramdisk or harddisk driver installation.

$472 is the vector to the get Bios Parameter Block function.
At boot time it points to the ROM code that performs this function for floppies.
At displacement of $20 of this ROM code there is an instruction that loads the address where TOS keeps its copy of the BPB for disk A.

So what the program initially fetches is a pointer to the TOS buffer of the BPB for disk A. It might seems a crazy ultra-undocumented way to do this. But the same piece of code is replicated in every TOS version. The address of the ROM routines changes, and the address of the BPB also changes. But because it seems that the source of this TOS routine was never changed, the $22 displacement is always valid.

This however should not work if a ramdisk or harddisk driver was installed before. Because then $472 will point to code into the new driver and of course that the $22 displacement won't be valid.

The displacement of $1C into the BPB is the location of the serial number of the disk.

User avatar
leonard
Moderator
Moderator
Posts: 640
Joined: Thu May 23, 2002 10:48 pm
Contact:

Postby leonard » Thu Aug 04, 2005 12:33 pm

But because it seems that the source of this TOS routine was never changed, the $22 displacement is always valid.


Are you sure of this ? Even falcon TOS ? what a chance ! :-)

The displacement of $1C into the BPB is the location of the serial number of the disk


Ok thanks for the info. The only doc I have for BPB structure was only 10 or 16bytes long, the $1c was far away. Do you have a complete BPB structure doc ?
Leonard/OXYGENE.

ijor
Hardware Guru
Hardware Guru
Posts: 2965
Joined: Sat May 29, 2004 7:52 pm
Contact:

Postby ijor » Thu Aug 04, 2005 1:51 pm

leonard wrote:
But because it seems that the source of this TOS routine was never changed, the $22 displacement is always valid.


Are you sure of this ? Even falcon TOS ? what a chance ! :-)


Ah, don't know. I only checked up to TOS 2.06.

Ok thanks for the info. The only doc I have for BPB structure was only 10 or 16bytes long, the $1c was far away. Do you have a complete BPB structure doc ?


Seems this is also undocumented.

User avatar
Mug UK
Administrator
Administrator
Posts: 11148
Joined: Thu Apr 29, 2004 7:16 pm
Location: Stockport (UK)
Contact:

Postby Mug UK » Thu Aug 04, 2005 1:58 pm

It's in my GFA source for PVK, it's also not quite documented, but covered in any of the bootsector installers source on my site as well as below:

Code: Select all

From start of side 0, track 0, sector 1; All words unless stated:

11 - bytes per sector
13 - sectors per cluster (BYTE)
17 - number of directory entries
19 - num sectors
22 - sectors per FAT
26 - sides
24 - sectors per track
28 - hidden sectors


(there's probably some bits missing though .. )

Look in the source that GGN did for the DIM convertor tool he wrote (also in GFA) as I think he covered the BPB a lot more.
My main site: http://www.mug-uk.co.uk - slowly digging up the bits from my past (and re-working a few): Atari ST, Sega 8-bit (game hacks) and NDS (Music ripping guide).

I develop a free Word (for Windows) add-in that's available for Word 2007 upwards. It's a fix-it toolbox that will allow power Word users to fix document errors. You can find it at: http://www.mikestoolbox.co.uk

ijor
Hardware Guru
Hardware Guru
Posts: 2965
Joined: Sat May 29, 2004 7:52 pm
Contact:

Postby ijor » Thu Aug 04, 2005 2:09 pm

Hi Muguk,

That's not the BPB, that's the boot sector structure. They are similar, but not exactly the same. The BPB is constructed by BIOS from the boot sector.

So one is an on-disk structure, the other is an on-memory structure. They have almost the same members, with a slightly different order and aligment. And with different endianess.

Btw, I didn't mean the BPB is not documented. The first 10 words (20 bytes) are documented. But seems that TOS internally mantains a 16 words (32 bytes) structure.

User avatar
Mug UK
Administrator
Administrator
Posts: 11148
Joined: Thu Apr 29, 2004 7:16 pm
Location: Stockport (UK)
Contact:

Postby Mug UK » Thu Aug 04, 2005 2:37 pm

Ah .. my mistake. Sorry Leonard and thanks ijor for the correction.
My main site: http://www.mug-uk.co.uk - slowly digging up the bits from my past (and re-working a few): Atari ST, Sega 8-bit (game hacks) and NDS (Music ripping guide).

I develop a free Word (for Windows) add-in that's available for Word 2007 upwards. It's a fix-it toolbox that will allow power Word users to fix document errors. You can find it at: http://www.mikestoolbox.co.uk

User avatar
leonard
Moderator
Moderator
Posts: 640
Joined: Thu May 23, 2002 10:48 pm
Contact:

Postby leonard » Thu Aug 04, 2005 8:56 pm

The first 10 words (20 bytes) are documented. But seems that TOS internally mantains a 16 words (32 bytes) structure


Ok that's what I found in my poor doc. It's amazing how big is the lack of technical document about these stuff. I don't find anything better on google.

R.Al surely makes its tools "empiricaly". Now suppose we want to do a "clean" version, just for the fun, anyone have an idea how to solve the "disk identifaction" problem in a clean way ? (I mean, knowing if it's the right disk when reading sectors on it?)

it's fun to though about ATARI TOS specific problem in 2005 ! :-)
Leonard/OXYGENE.

User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2192
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Postby lp » Thu Aug 04, 2005 9:11 pm

Some mentioned this PDF. Here it is.
You do not have the required permissions to view the files attached to this post.

ijor
Hardware Guru
Hardware Guru
Posts: 2965
Joined: Sat May 29, 2004 7:52 pm
Contact:

Postby ijor » Thu Aug 04, 2005 9:27 pm

lp wrote:Some mentioned this PDF. Here it is.


Great! Thanks a lot lp.

Now Leonard, download the PDF and never ever dare to leave your home without it ! :)

Regarding the "clean way" stuff. It's a bit tricky, mainly because Atari media change detection is broken. I'll give it a thought and let you know.

User avatar
leonard
Moderator
Moderator
Posts: 640
Joined: Thu May 23, 2002 10:48 pm
Contact:

Postby leonard » Thu Aug 04, 2005 9:32 pm

Now Leonard, download the PDF and never ever dare to leave your home without it !


:-) Yeah I'll try it !

Unfortunatly the download button fail here (maybe the file is too big for the forum ?)

hey lp, do you have an internet URL to provide ? I'm very curious about that bible !! :-)
Leonard/OXYGENE.

User avatar
Mug UK
Administrator
Administrator
Posts: 11148
Joined: Thu Apr 29, 2004 7:16 pm
Location: Stockport (UK)
Contact:

Postby Mug UK » Thu Aug 04, 2005 9:39 pm

Works for me on right-click, save target as. Downloading it just sits in limbo.
My main site: http://www.mug-uk.co.uk - slowly digging up the bits from my past (and re-working a few): Atari ST, Sega 8-bit (game hacks) and NDS (Music ripping guide).

I develop a free Word (for Windows) add-in that's available for Word 2007 upwards. It's a fix-it toolbox that will allow power Word users to fix document errors. You can find it at: http://www.mikestoolbox.co.uk


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 2 guests