Path: utzoo!mnetor!uunet!husc6!think!ames!pasteur!ucbvax!MITRE-BEDFORD.ARPA!jhs From: jhs@MITRE-BEDFORD.ARPA Newsgroups: comp.sys.atari.8bit Subject: boot disks Message-ID: <8803290341.AA03091@mitre-bedford.ARPA> Date: 29 Mar 88 03:41:48 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 58 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