[net.micro.atari8] boot sectors questions

curzon@kaoa01.dec.com (10/23/86)

Can anyone give the lowdown on the boot sectors of an Atari disk?

ie: how the "boot" ROM routines work, 
    what parameters are picked up from the disk,
    where are they located,
    what functions served by the boot sector code vs
     the DOS itself
    differences between the boot sectors on a DOS disk
     and a "boot" disk
    and anything else that is interesting or relevant!

                    Thanks

				Dick Curzon
				Digital Equipment of Canada
                                PO Box 13000
                                Kanata Ontario      K2K 2A6
                                Canada.


(DEC E-NET)	KAOA01::CURZON
(UUCP)		{decvax, ucbvax, allegra}!decwrl!kaoa01.dec.com!curzon
(ARPA)		curzon%kaoa01.DEC@decwrl.ARPA

hans@umd5 (Hans Breitenlohner) (11/04/86)

In article <6074@decwrl.DEC.COM> curzon@kaoa01.dec.com writes:
>Can anyone give the lowdown on the boot sectors of an Atari disk?
>
   First boot sector:
      Byte 0:  A flag byte.  As far as I know nobody uses it for anything.
          It ends up at location $240 (more on that later).
          This is zero for most disks I have looked at, but not all.
      Byte 1:  Number of sectors to be loaded by the ROM boot code.
      Bytes 2,3:  Memory address to load first boot sector (including the
          first 6 bytes) in low byte, high byte format.
      Bytes 4,5:  Address (low byte, high byte) of startup code.
      Byte 6 and up:  Initialization code (note: this is the code itself,
          not the address of the code).

   Boot procedure:  (this applies primarily to an XL system, I can only
     assume that 400/800's are similar).
After machine initialization is complete, the disk boot routine is called.
If disk unit 1 is present, it reads sector 1 to address $400.  The first four
bytes are copied to $240.  The next two bytes are copied to $0C and $0D.
The whole sector is then copied to the address given in bytes 2 and 3.
Sectors are then read in sequence and copied to memory behind the first.
The count at $241 is
decremented as sectors are read, and will be zero when the boot is done.
Next the initialization code will be called, using a JSR instruction.  If
it returns with the carry flag set, the BOOT ERROR message is displayed, and
the boot process will be repeated.  
Next the startup code will be called through the vector at $0c, $0d, again
via JSR.
Upon returning location $9 will be set to 1, indicating successful disk boot.
Next a subroutine to load a relocatable peripheral handler is executed.   I
have no idea what it is meant to do, except that it probably won't do anything
unless you have a strange peripheral on your serial bus.  (If anyone can shed
light on this, please post!)  After that $244 is set to zero, indicating
that a warm start can be done for the next reset.  
Finally, either a JMP ($BFFA) or a JMP ($000A) is performed, depending on
whether a cartridge (or built in basic) exists, and the cartridge's option
byte.

Notes:
1.  Either the initialization or the startup code must put an appropriate
   address at location $0A and $0B.  This vector will be used when
   initialization is complete, and on subsequent warm starts.
2.  The ROM boot code can only deal with 128 byte sectors.  To work with double
   density disks, only the first three sectors of a disk may be used in the
   boot, anything else must be read by user supplied routines.  This, of
   course, is the reason for the peculiar sector lengths for the first
   three sectors of double density disks.
3.  For DOS disks, the three boot sectors contain mainly pointers, the
   disk i/o routines, and the initialization code.  The initialization code
   loads DOS.SYS (i.e. FMS and the resident portion of DOS).  The startup code
   sets the DOS vector (at $0A, $0B) to a routine which loads DUP.SYS,
   initializes buffers and disk drive tables, loads and runs AUTORUN.SYS
   if there is one, and then returns.  After boot
   completion (or when calling DOS from BASIC) the non-resident part of
   DOS will be loaded and executed.

Most of this is extracted from:
  Mapping the Atari by Ian Chadwick
  Inside Atari Dos by Bill Wilkinson
  and disassemblies of code (i.e. DOS and OS ROMs).


I hope this is what you were looking for!