Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!ames!vsi1!zorch!amiga0!mykes From: mykes@amiga0.SF-Bay.ORG (Mike Schwartz) Newsgroups: comp.sys.amiga.programmer Subject: Re: Programming Boot Blocks?? Message-ID: Date: 31 Mar 91 09:36:09 GMT References: <1991Mar31.001655.3973@maverick.ksu.ksu.edu> Organization: Amiga makes it possible Lines: 57 In article <1991Mar31.001655.3973@maverick.ksu.ksu.edu> set@phobos.cis.ksu.edu (Steve E Tietze ) writes: > >How would I go about programming my own boot block? Where can I get info on >this? > > ><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><-> ><-> AMIGA MAN! ***Kansas State University*** Steve Tietze <-> ><-> Email set@phobos.cis.ksu.edu Phone 913-539-9101 <-> ><-><-><-><-><-><-><->And Justice for All ... Metallica<-><-><-><-><-><-><-> To quote AmigaMail (sent to registered developers): On floppy disks, the boot block will also contain boot code which is responsible for initializing DOS when booting from a floppy. Blocks 0 and 1 of the 3.5" floppy are reserved as BootBlocks. Block 0 of a Kickstart disk contains a BootBlock structure with a bb_id of "KICK". Blocks 1 through 512 contain the binary image of KickStart. Block 0 of a bootable DOS disk starts with a bootblock structure with a bb_id of "DOS\0", followed currently by the boot code shown below, or alternate boot code in the case of some games. /* BootBlock definition: */ struct BootBlock { UBYTE bb_id[4]; /* 4 character identifier */ LONG bb_chksum; /* boot block checksum (balance) */ LONG bb_dosblock; /* reserved for DOS patch */ }; The article goes on to show the source code to the official bootblock program (in assembler). The comments at the top of the source file show that: it is called with: A1 = ptr to IOB to the disk (must be closed unless we return) A6 = sysbase In english, what all this means is that the boot sector is 1024 bytes long. The first 12 bytes of this 1024 byte block must be initialized to "DOS\0" followed by 2 longwords of zero. Following this 12 byte header, you can put whatever boot block program you want. It is real nice that A1 and A6 are set up for you already to use Trackdisk.device. To install the bootblock on disk, you write a program ('C' works well for this application) that reads in your 1024 byte executable (as output by your assembler/linker). The program must then calculate the checksum. This is done by adding up all 1024 bytes (actually 256 longwords), negating it (multiply by -1) and stuffing it into the bb_chksum field. The program then uses trackdisk.device to write the 1024 bytes to blocks 0 and 1 of the floppy. That's all there is to it. -- ******************************************************** * Appendix A of the Amiga Hardware Manual tells you * * everything you need to know to take full advantage * * of the power of the Amiga. And it is only 10 pages! * ********************************************************