News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Bootstrapping from FAT formatted floppy disk?

Started by Benedikt, 19:57, 15 May 24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Benedikt

Imagine the following scenario:

  • A 3.5" drive is connected as drive B
  • The disk in it has a FAT file system
  • It already contains binaries for some other platform(s), e.g. MS-DOS, MSX-DOS, Enterprise 128, Atari ST
  • We want an additional binary for CPCs

Is there any somewhat convenient way to load and run anything from that disk from Basic?
E.g. a few lines to load a "CPCDOS.SYS" from a known, continuous sequence of sectors?

Thank you in advance!


andycadley

Assuming you have a DOS capable of reading from FAT, you could just store some CPC binary on there. There's nothing in the FAT filesystem for reserving special sectors for a given machine though.

Benedikt

And is there any way to just read a specific sector in a file system agnostic way using Basic and to run it as machine code?
Putting a write-protected system file in a known sequence of sectors is solved problem.

The question is about bootstrapping, i.e a DOS with the relevant capabilities is not already running.

Prodatron

There is

BPB_RsvdSecCnt

"Number of reserved sectors in the Reserved region of the volume
starting at the first sector of the volume. This field must not be 0.
For FAT12 and FAT16 volumes, this value should never be
anything other than 1. For FAT32 volumes, this value is typically
32."

So as all discs are FAT12, there is no chance for having additional reserved sectors at fixed LBAs beside the boot sector.
But you can always reserve clusters on a FAT device using the FAT itself without assigning them to a file (a PC then may want to repair the disc :) ). If you have always the same disc size, this could be done at fixed LBAs (tracks/sectors).

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

andycadley

Quote from: Benedikt on 20:22, 15 May 24And is there any way to just read a specific sector in a file system agnostic way using Basic and to run it as machine code?
Putting a write-protected system file in a known sequence of sectors is solved problem.

The question is about bootstrapping, i.e a DOS with the relevant capabilities is not already running.
The only way from BASIC is |CPM which loads track 0, side 0 sector &41. It will only load 512 bytes though (whatever is booted is then expected to load the rest). 

Benedikt

Quote from: Prodatron on 22:31, 15 May 24But you can always reserve clusters on a FAT device using the FAT itself without assigning them to a file (a PC then may want to repair the disc :) ).
Reserving clusters by putting a file there sounds like a more intuitive and more robust option.
Ideally a hidden, write-protected system file or something.

Quote from: andycadley on 22:49, 15 May 24The only way from BASIC is |CPM which loads track 0, side 0 sector &41. It will only load 512 bytes though (whatever is booted is then expected to load the rest).
In that case I will have to resort to some hideous CALL trickery, because |CPM only works with drive A and I need drive B.
Hopefully I can come up with something that is short enough to be usable.

andycadley

Quote from: Benedikt on 15:59, 16 May 24In that case I will have to resort to some hideous CALL trickery, because |CPM only works with drive A and I need drive B.
Hopefully I can come up with something that is short enough to be usable.

I'm not really sure you need any trickery. You can just RUN a binary file, provided the header is correctly set up for it.

Benedikt

The RUN command is probably not particularly useful for loading a FAT driver from a FAT formatted disk.

But in the meantime I came up with this code snippet, which should be roughly equivalent to |CPM:

kl_find_command equ 0bcd4h

entry:
        ld      hl,read_sector_rsx
        call    kl_find_command
        ld      (read_sector),hl
        ld      (read_sector+2),c
        ld      hl,100h                 ; destination address
        push    hl                      ; also save as return address
        ld      de,read_sector          ; load address of far pointer
        push    de                      ; save address of far pointer on stack
        ld      de,0001h                ; (track << 8) | drive
        ld      c,41h                   ; sector
        rst3                            ; far call via stack; "returns" to 100h

read_sector_rsx db  84h                 ; ID "string" of the RSX function
read_sector     db  ?                   ; far pointer

Could something like this work, if massaged into a Basic CALL statement?

andycadley

I don't think AMSDOS can read sectors from a format it doesn't know about, but I'll let someone more knowledgeable answer that for sure.

HAL6128

#9
If the 3,5 inch floppy disc is a Double Density Disc (up to 720k / 840k) then it shouldn't be a problem to read a sector with AMSDOS?? (Doesn't MS-DOS up to version 3.3 used FAT12 on DD floppies?)
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

Prodatron

Quote from: andycadley on 19:16, 16 May 24I don't think AMSDOS can read sectors from a format it doesn't know about, but I'll let someone more knowledgeable answer that for sure.
AFAIK the low level "Read Sector" (#84) command of Amsdos can handle any sector IDs with "format offset" (this CP/M hack using the high nibble for detecting the disc parameters).
So you should be able to read FAT sectors (which don't use the high nibble... - FAT provides useful disc parameters in the boot sector) with Amsdos.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Powered by SMFPacks Menu Editor Mod