[net.micro.atari8] boot mysteries

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

Can anyone help me figure out 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 on a "boot" disk;
    and anything other tidbits!

                    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

edsxdev0@ihlpm.UUCP (Daryl Monge) (11/01/86)

> 	 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 on a "boot" disk;
>     and anything other tidbits!

References: Atari Personal Computer System Operating System Manual
	    Inside ATARI DOS, Compute Books

The OS ROM reads the first sector of the disk into the cassette buffer at
0x400.  The Control info is as follows:
	Flags		Moved to 0x240, but otherwise unused for booting.
	#sectors	The number of sectors to read
	loadaddr	The memory address (low,high) to place #sectors
			read.  Saved in 0x242
	initaddr	The initialization address when the boot is complete.
			Saved in DOSINI (0xC).  Also called during system
			reset.
	<Boot code>

This first sector, which has been temporarily saved in the cassette buffer
is moved into the address specified by loadaddr.  The remaining number of
records specified are then read in.  Control is then passed to (loadaddr+6)
to continue the boot process.  The boot process must return the carry reset
to indicate success.  Then a JSR is done through initaddr and then a JMP to
DOSVEC is done.  (my comment: One would assume that the boot code would set
up DOSVEC, since it is not mentioned in the boot process above).

Pressing system reset causes the JSR DOSINI and JMP DOSVEC to be done.

You may observe that the most simple of boot programs can simply set up
memory as is needed, with the first 6 bytes correctly set, then write memory
directly to disk, sector by sector.  My suspicion is that is the technique
normally used by games and such that do not require a file system on the
disk.

DOS 2.0S uses this process in a specific way.  The first 3 disk sectors hold
the boot code.  This boot code knows how to process files in the file system
on the disk and hence do the actual load of DOS.SYS.  The boot record actually
looks like the following (DOS 2.0S.  I don't know about others)
	Flags			as before
	#sectors
	loadaddr
	initaddr
	JMP XBCONT		Jump to the DOS.SYS boot code
<Here begins DOS II specific configuration info>
	SABYTE			number of sector buffers to allocate
	DRVBYT			drive bits.  See your DOS II manual
	<unused>
	SASA			buffer start addr
	DFSFLG			DOS flag, set when DOS.SYS has been written
	DFLINK			sector pointer to the first sector of the
				DOS.SYS file.  Handy since it eliminates 
				processing of the directory.
	BLDISP			used when a 256 byte sector drive is used.
	DFLADR			Address to start loading DOS.SYS

Actually, the boot process is very clean and easy to understand.  I am
continually amazed at how cleanly the ATARI 8 bit OS is built.  I have
left out much detail from the two quoted references for brevity.  Anyone
actually interested in using such facilities would be well advised to get
the above referenced documentation, or equivalent.

The major piece of information I do not have is if (how?) DOS 2.5, DOS 4.0,
Sparta DOS, etc., have modified the extended boot procedure used by DOS 2.0S
after the ROM boot procedures have loaded the primary boot code?  Anyone
care to add some info here?

Daryl Monge			UUCP:	...ihnp4!ihelp!dlm
AT&T				CIS:	72717,65
Bell Labs
Naperville, Il.