[comp.sys.atari.8bit] boot disks

jhs@MITRE-BEDFORD.ARPA (03/28/88)

>  Does anyone know how to set up a disk that will boot up without DOS
>  and without an AUTORUN.SYS?  I am interested in writing games for
>  the 800XL and want disks to self boot, etc.

The structure of the boot sector is described in gory detail in "Inside Atari
DOS" and I think also in "de re Atari".  I don't have these references at hand
right now but if you can't locate them I can try to tell you the salient
points.

-John Sangster / jhs@mitre-bedford.arpa

jhs@MITRE-BEDFORD.ARPA (03/29/88)

For Steven Klassen and anyone else who cares, here is a brief description of
the boot process.  When you power up with a disk drive attached and turned on,
and with a disk in it, etc., the O/S will read the first sector of the disk
into memory starting at address $0700 and then will look at what it got to
determine how to proceed.  The first few bytes of data loaded have the
following meanings:

	$0700   BFLAG   Flag (normally 0)
	$0701   BRCNT   Boot Record Count (nr of consec sectors to read into
			  memory for boot record (typically 3).
	$0702   BLDADR  Boot Load Address, i.e. where to put the stuff.
	$0704   BIWTARR Initialization address
	$0706   JMP XBCONT  This is an actual jump instruction followed by
				a 2-byte address indicating where to go.
	$0709   SABYTE  Number of sector buffers to allocate
	$070A   DRVBYT  Bit map of the disk drive unit numbers to plan for.
	$070B           Unused
	$070C   SASA    Buffer Start Address
	$070E   DFSFLG  DOS Flag
	$070E   DFLINK  Sector at which DOS.SYS starts
	$070F   BLDISP  Displacement in sector to sector link (differs for
				DD versus SD disk format).
	$0712   DFLADR  Address for loading DOS.SYS file.

This nomenclature assumes you will want to load DOS from the disk, as you
would if your program planned to do disk I/O in the normal way, i.e. using
DOS services.  If not, some of the DOS-related names should still give you
a clue as to what the loader will try to do with these locations.

First the O/S loads BRCNT consecutive sectors into memory starting with the
first sector (sector 1) starting at BLDADR.  Then it will do a JSR into the
7th byte into the area loaded, i.e. BLDADR+$6, or the JMP instruction at
$0706 in the above listing.  If what you are booting is a DOS disk, then the
address XBCONT will lie in the block of sectors initially loaded and the code
there will already be in place and will continue the load in whatever way
strikes its fancy.

If you are booting your own thing without DOS, then evidently you need to
start sector 1 with a 0 byte, then a byte containing the number of sectors
you want loaded in the first gulp, then 2 bytes saying where to load these
sectors, then 2 bytes saying where to JMP to initialize the program, and
finally -- 6 bytes into the load area -- a JMP to the code you have provided
to continue the load process.  Everything after $0706 is apparently up to you.
In particular, the initialization address called BIWTARR at $0704 will only
get used if your code references it, I believe.  By the way, if BRCNT is set
to zero it is interpreted as 256 sectors, so you can let the bootstrap loader
load a whole program if it is anywhere up to 256 sectors long, so long as the
sectors are contiguous.  If it is longer or non-contiguous, you will have to
provide code to read the sector links and figure out where to go for the next
sector.

I hope this is enough to get you started.  I also hope it is true.  I am
playing back what they say in "Inside Atari DOS", which pertains to DOS 2.0S.
Your DOS may differ, depending on road conditions and your style of driving.
I'm sure there are other readers of this august journal who can give you
the benefit of their greater experience with how it all REALLY works.

-John Sangster / jhs@mitre-bedford.apra

swklassen@trillium.waterloo.edu (Steven W. Klassen) (03/29/88)

In article <8803281528.AA09139@mitre-bedford.ARPA> jhs@MITRE-BEDFORD.ARPA writes:
>The structure of the boot sector is described in gory detail in "Inside Atari
>DOS" and I think also in "de re Atari".  I don't have these references at hand
>right now but if you can't locate them I can try to tell you the salient
>points.

Please post this info to the net.  I'm sure that there are enough people
who do not have access to these publications but would appreciate the
info to warrent posting it.

Steven Klassen
Computer Science Major
University of Waterloo

cfchiesa@bsu-cs.UUCP (Christopher Chiesa) (03/31/88)

In article <6071@watdragon.waterloo.edu>, swklassen@trillium.waterloo.edu (Steven W. Klassen) writes:
> In article <8803281528.AA09139@mitre-bedford.ARPA> jhs@MITRE-BEDFORD.ARPA writes:
> >The structure of the boot sector is described in gory detail in "Inside Atari
> >DOS" and I think also in "de re Atari".  I don't have these references at hand

Does anyone around here have a copy of Inside Atari DOS, or know where to get
one?  I've been having a heck of a time trying to find it, since last seeing
it and (in retrospect, stupidly) NOT buying it, back around 1983 or 4.  Rumor
has it that it's out of print, but does anyone know for sure?  If all else 
fails, I'd love to have the hotline (800 number or otherwise) to COMPUTE!
themselves, so I could get the scoop "straight from the horse's mouth."

E-mail or post here.  Thanks.

Chris Chiesa

-- 
UUCP: <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!cfchiesa 
cfchiesa@bsu-cs.UUCP                                           

cfchiesa@bsu-cs.UUCP (Christopher Chiesa) (03/31/88)

In article <6071@watdragon.waterloo.edu>, swklassen@trillium.waterloo.edu (Steven W. Klassen) writes:
> In article <8803281528.AA09139@mitre-bedford.ARPA> jhs@MITRE-BEDFORD.ARPA writes:
> >The structure of the boot sector is described in gory detail in "Inside Atari
> >DOS" and I think also in "de re Atari".  I don't have these references at hand
> >right now but if you can't locate them I can try to tell you the salient
> >points.
> 
> Please post this info to the net.  I'm sure that there are enough people
> who do not have access to these publications but would appreciate the
> info to warrent posting it.

Due to this and other requests received through E-mail, I am in the process
of composing a description of the boot process, necessary disk format, and
so on, which I will try to get posted to this newsgroup within the next few
days.  I'm taking the info presented in the Atari OS User's Manual and ren-
dering it into comprehensible terms.  I don't know 'bout YOU, but I've always
felt that there were lots of huge gaps in the docs for this machine, and what's
there often isn't very clear!  I'm trying to avoid that in my summary, so 
please bear with me.

Chris Chiesa


-- 
UUCP: <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!cfchiesa 
cfchiesa@bsu-cs.UUCP                                           

elk@BUENGC.BU.EDU (Edward L. Bayiates) (04/01/88)

Unfortunatly[D  (bad keyboard) Unfortunately, I have neither...do
you happen to know where to get theM (especially DeRe Atari?)

Thanks,

Ed Bayiates (elkbuengc.byu  elk buengc.bu.edu)

cfchiesa@bsu-cs.UUCP (Christopher Chiesa) (04/02/88)

In article <8803290341.AA03091@mitre-bedford.ARPA>, jhs@MITRE-BEDFORD.ARPA writes:
      [introductory text omitted; remaining text edited for brevity and
       to satisfy the line-counter... grrr...]

> .. brief description of the boot process. ... O/S will read the first sector 
> of the disk into memory starting at address $0700 and then will look... to 
> determine how to proceed.  The first few bytes of data loaded have the
> following meanings:
> 
> 	$0700   BFLAG   Flag (normally 0)
> 	$0701   BRCNT   Boot Record Count (nr of consec sectors to read into
> 			  memory for boot record (typically 3).
> 	$0702   BLDADR  Boot Load Address, i.e. where to put the stuff.
> 	$0704   BIWTARR Initialization address
> 	$0706   JMP XBCONT  This is an actual jump instruction followed by
> 				a 2-byte address indicating where to go.

According to the Atari Operating System User's Manual, these six bytes are
ALL you need concern yourself with for a pure autoboot disk; the remaining
bytes are specific to the DOS 2.0 boot process, which the OS User's Manual 
cites specifically as a "special case of diskette-booted software."

> 	$0709   SABYTE  Number of sector buffers to allocate
> 	$070A   DRVBYT  Bit map of the disk drive unit numbers to plan for.
> 	$070B           Unused
> 	$070C   SASA    Buffer Start Address
> 	$070E   DFSFLG  DOS Flag
> 	$070E   DFLINK  Sector at which DOS.SYS starts
> 	$070F   BLDISP  Displacement in sector to sector link (differs for
> 				DD versus SD disk format).
> 	$0712   DFLADR  Address for loading DOS.SYS file.
> 
    [interpretation of byte functions omitted]

This set of locations are DOS-related ONLY, and aren't significant to the
boot process itself.  They can, and often do, contain executable code.
The special functions above are valid only when the program to be booted is 
the DOS.SYS portion of DOS 2.0.

    [process description omitted]

> (you can autoboot a program...) up to 256 sectors long, so long as the
> sectors are contiguous.  If it is longer or non-contiguous, you will have to
> provide code to read the sector links and figure out where to go for the next
> sector.

This is important to remember, because the boot process doesn't use the 
concept of "files" on the disk; unless you load in your own file management
software, too, you won't be ABLE to access the disk as files -- no directory,
no VTOC, will exist except as managed by YOUR program.  The built-in disk
handler in the computer operates ONLY at the SECTOR level. 

> 
> I hope this is enough to get you started.  I also hope it is true.  I am
> playing back what they say in "Inside Atari DOS", which pertains to DOS 2.0S.
> Your DOS may differ, depending on road conditions and your style of driving.
> I'm sure there are other readers of this august journal who can give you
> the benefit of their greater experience with how it all REALLY works.

As far as I can tell, John got it right.  In fact, his posting is so con-
cise that it obviates any need for me to duplicate his effort by posting
my own long-winded version.  On the other hand, I remember being EXTREMELY
confused and uninformed by manuals explaining things by saying "load stuff
starting at LDADR and then jump through DOSINI" or whatever; if there's
anyone reading this who doesn't follow the notation, make sure you speak up.
I hated that more than anything, but had to bull through it without benefit
of the net; as a result, progress has been slow... you have a chance to do
better, so take advantage!

> 
> -John Sangster / jhs@mitre-bedford.apra


-- 
UUCP: <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!cfchiesa 
cfchiesa@bsu-cs.UUCP