[comp.sys.amiga.programmer] Programming Boot Blocks??

set@phobos.cis.ksu.edu (Steve E Tietze ) (03/31/91)

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<-><-><-><-><-><-><->

mykes@amiga0.SF-Bay.ORG (Mike Schwartz) (03/31/91)

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! *
********************************************************

DXB132@psuvm.psu.edu (04/01/91)

>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?
>>

I wrote a nice (I think it's nice :-) article in the first (January)
Amazing Tech describing a rather fancy bootblock. The disk with the
magazine includes a nice utility to manipulate bootblock, too. (This
could be done in AmigaMon as well).

The article also has the only *understandable* explaination of
autobooting (and related issues) that I've seen...not to toot my
own horn...:-)

-- Dan Babcock

yorkw@stable.ecn.purdue.edu (Willis F York) (04/01/91)

DXB132@psuvm.psu.edu writes:
>I wrote a nice (I think it's nice :-) article in the first (January)
>Amazing Tech describing a rather fancy bootblock. The disk with the
>magazine includes a nice utility to manipulate bootblock, too. (This
>could be done in AmigaMon as well).

>The article also has the only *understandable* explaination of
>autobooting (and related issues) that I've seen...not to toot my
>own horn...:-)

Gee was that articial that made a Bootblock that Mounted rad:
copied df0: to rad: then booted offa rad?

I could ALMOST use it. Problem i have is.

1) I must use AdMem to get my memory (It's NOT autoconfig. _
2) I only got 1.2 roms. (Why bother getting 1.3, 2.0 should be out Soon Right?)

So how hard would it be to get a bootblock that
add's expansion memory., Then Copies df0: to rad:

Then upon a reboot, admem's mount's rad: and Checks rad: to see if
it should boot from there?

-----
Just wondering how complex a Botblock could be.. :^)
.

--
yorkw@ecn.purdue.edu  aka Willis F York   aka Squid on IRC 
The only thing that Apple invented is the idea to borrow Xerox-invented ideas.  
(Hope THIS sig don't insult anyone!)   :^) 

avenger@wpi.WPI.EDU (Samuel Joseph Pullara) (04/01/91)

>>>>> On 31 Mar 91 20:08:52 GMT, yorkw@stable.ecn.purdue.edu (Willis F York) said:

>> DXB132@psuvm.psu.edu writes:
>I wrote a nice (I think it's nice :-) article in the first (January)
>Amazing Tech describing a rather fancy bootblock. The disk with the
>magazine includes a nice utility to manipulate bootblock, too. (This
>could be done in AmigaMon as well).

>The article also has the only *understandable* explaination of
>autobooting (and related issues) that I've seen...not to toot my
>own horn...:-)

>> Gee was that articial that made a Bootblock that Mounted rad:
>> copied df0: to rad: then booted offa rad?

>> I could ALMOST use it. Problem i have is.

How 'bout a program that mounts ffs for all of us 1.2ers and then
boots off the ffs disk in the drive?
--
/------------------------------------------------------------------------\
| Sam Pullara, Undergraduate Physics     Worcester Polytechnic Institute |
| avenger@wpi.wpi.edu                      (c) 1990 Avenger Publications |
|______________-All my opinions were expressed or implied.-______________|

hbrinch@icoast.UUCP (Henrik Brinch) (04/01/91)

In article <1991Mar31.001655.3973@maverick.ksu.ksu.edu>, Steve E Tietze  writes:

> 
> How would I go about programming my own boot block?  Where can I get info on
> this?

It isn't too hard, try ie. the Abacus book called "Amiga Disk Drives Inside
and Out" (english) or "das grosse floppybuch" (DataBecker - German).
The two books are identical, they explain how to do a boot-block and a lot
more.

> <->   AMIGA MAN!    ***Kansas State University***   Steve Tietze        <->

Best Regards,

InfoCoast       /\  /\_  Henrik Brinch \ cbmehq!cbmdeo!icoast!hbrinch
Technologies /\/  \/   \ Kloevervej 7   \ FidoNet 2:230/112.3
____________/  \  /     \ 2800 Lyngby    \ Voice/Fax tel.# +45 42 87 67 23
           /    \/       \  Denmark       \ "C is SILVER - But ASM is GOLD"

rhialto@cs.kun.nl (Olaf'Rhialto'Seibert) (04/05/91)

In article <yorkw.670450132@stable.ecn.purdue.edu> yorkw@stable.ecn.purdue.edu (Willis F York) writes:
>DXB132@psuvm.psu.edu writes:
>Gee was that articial that made a Bootblock that Mounted rad:
>copied df0: to rad: then booted offa rad?
>
>I could ALMOST use it. Problem i have is.
>
>1) I must use AdMem to get my memory (It's NOT autoconfig. _

I have that problem myself. Therefore I wrote a nifty little program
that creates a ROM-Tag and survives reboots. It is called
AddMemForever (or AMF for short) and has been posted on comp.sources.
amiga. It should therefore be available from your nearest archive
site.

One problem: it does not work with 2.0, it seems, since I heard they
changed the ROMTag principle. (Anyone care to explain more details?)

>yorkw@ecn.purdue.edu  aka Willis F York   aka Squid on IRC 
--
Olaf 'Rhialto' Seibert                               rhialto@cs.kun.nl
How can you be so stupid if you're identical to me? -Robert Silverberg

yorkw@stable.ecn.purdue.edu (Willis F York) (04/05/91)

rhialto@cs.kun.nl (Olaf'Rhialto'Seibert) writes:
>>1) I must use AdMem to get my memory (It's NOT autoconfig. _

>I have that problem myself. Therefore I wrote a nifty little program
>that creates a ROM-Tag and survives reboots. It is called
>AddMemForever (or AMF for short) and has been posted on comp.sources.
>amiga. It should therefore be available from your nearest archive
>site.

Do ya mean to say that ALL memory boards get added the same way?

Interesting, I'll have to look at it.

(Can ya put it in a Boot block?)

--
yorkw@ecn.purdue.edu  aka Willis F York   aka Squid on IRC 
The only thing that Apple invented is the idea to borrow Xerox-invented ideas.  
(Hope THIS sig don't insult anyone!)   :^) 

rhialto@cs.kun.nl (Olaf'Rhialto'Seibert) (04/12/91)

In article <yorkw.670821918@stable.ecn.purdue.edu> yorkw@stable.ecn.purdue.edu (Willis F York) writes:
>rhialto@cs.kun.nl (Olaf'Rhialto'Seibert) writes:
>>I have that problem myself. Therefore I wrote a nifty little program
>>that creates a ROM-Tag and survives reboots. It is called
>>AddMemForever (or AMF for short) and has been posted on comp.sources.
>>amiga. It should therefore be available from your nearest archive
>>site.

>Do ya mean to say that ALL memory boards get added the same way?

I am not sure what you mean, but you can select the priority for each
memory block separately, (but it may be that I added the capability
to add multiple blocks from a simple table only after I released it,
just for fun because I don't need it myself).

>Interesting, I'll have to look at it.

>(Can ya put it in a Boot block?)

Yes, with some small modifications this should be possible. The main
thing the code does is allocate some memory, copy the RomTag + code
into it, and add the RomTag to the appropriate list. It also runs the
code, of course, if needed. This is so you can stick it into your
Startup-Sequence without causing the memory to be added twice.

>yorkw@ecn.purdue.edu  aka Willis F York   aka Squid on IRC 
>The only thing that Apple invented is the idea to borrow Xerox-invented ideas.  
--
Olaf 'Rhialto' Seibert                               rhialto@cs.kun.nl
How can you be so stupid if you're identical to me? -Robert Silverberg