TOS 1.04 patch for  better FAT16  filesystem
I will name it TOS 1.05 for now, it may change way of using mass storage with old Ataris
 
 
Limitations of Atari ST TOS in working with hard disks are pretty well known: despite it is intended to be compatible with widely used DOS FAT16 disks, partitions - so with all swapped bytes in FAT, MBR , it is compatible only in case of partitions under 32 MB size. There is partition size limit of 512 MB in case of TOS 1.04 and higher. TOS uses so called large sectors in case of partitions over 32 MB size, and it is not efficient way. It means for instance that in case of some partition in range of 257-511 MB, when need to read only 512 bytes from drive, it must read 8 KB, because it is logical sector size. And today, with modern storage, most of people creates larger partitions.
I was thinking about improving this already some 10 years ago. I seen approx. what is the problem in TOS 1.04 with FAT16 filesystem. Main problem is that sector addressing is with 16-bit variable instead 32-bit one. Other problem is using signed variable for cluster number, so max cluster count is not 2 pow 16, but just 2 pow 15 - what means max some 32500 clusters - and worse, it means smaller max partition size.
Finally, I did this patching - it was extremely hard. Code is done with some ancient C-compiler in 1989, and that was pretty hard to follow. Certainly, things would be easier with complete C source of TOS 1.04, but there is no such. There are some sources for TOS filesystem, but here, we need all variables of TOS 1.04, otherwise whole RAM usage will be messed up. So, I decided to perform all changes in disassembled TOS 1.04 S file, keeping all variables intact. There was place for expanding 16-bit variable to 32-bit one in BCB and OFD structures. Most of it happens on stack, and a6 link space anyway in C code. I done changes at about 200 places, and resulting code would be longer, so would not fit before AES, but luckily there was lot of addressing what can be converted to short (TOS variables are mostly in lowest 32KB), so I shortened it some 512 bytes just by it, and that was only for part of TOS. Harder part was making real 16-bit FAT to work, but it is OK now, and with this:

Max partition size is now 1GB. It is better than Falcon's 1 GB, since clusters are shorter (16 KB vs. 32 KB)
It is DOS FAT 16 compatible, so no need for BigDOS or DOS/TOS compatible partitioning - you may access DOS partitions (created by Windows or some PC partitioning SW) up to 1GB. Of course, this can work in same mode as original TOS 1.04 filesystem, so access to TOS(AHDI) type partitions works still - and it can be better with proper driver - then will access them in short sector mode.
No need for extra buffers, because no large sectors. That means that RAM usage of hard disk driver may be only some 5-6 KB totally.
Of course, some extra buffers can make it faster, but now, it will be optional and not mandatory.
Disk access is more efficient because no large sectors.


Booting with old DOS type driver - but now no need for BigDOS :
p/boot1gp.png

View of 1GB partition content:
p/view1gp.png
     

And here is first extra problem - above pic is done with TOS 2.06 combined with this TOS 1.05 filesystem. In TOS 1.04 displaying of larger file sizes in Text view mode works not - it crashes when is above 100 MB. So, it will need some patch of Desktop part of 1.04 too ...
Luckily, no problems in Icon view mode.

And there is it in patched 1.04, with now added large file displaying fix:
p/largfsf.png

Some people certainly noticed those crashes when used TOS 1.xx in emulators, with GEMDOS hard disk emulation (so some DIR on PC assigned for Atari logical drive, like C: ) - it crashes in Text view mode if there are some very large files (above 100MB) . So, this fix is good for it too.

I made simple test program which measures disk access data flow. Tested with pretty much average SW - starting some medium long program what loads couple shorter and longer files:  with usual large logical sectors of AHDI/TOS partition it was 294912 bytes loaded from disk. Running same SW, from same place, but with 512 byte sectors resulted in 225792 bytes loaded from disk. Or 30% less . There is just too much overhead with large sectors, especially in case of many shorter files, or many short data chunk accessing.

Future plans: Making special hard disk driver, what will utilize this real FAT16 capability of modded TOS. With some extra buffer settings as option. RAM usage with regular buffers (which are always there in TOS) can be some 5 KB only. Extra buffers can improve speed, so it's on user when will activate them.
Doing same mod with TOS 1.62, so for STE machines.
I may selling programmed chips with this modded TOS. There will be some other patches too inlufrf - like IDE autoboot support, special TOS AUTO folder run patch for max RAM for user SW ...







    PP,  Jan-Febr.  2018.