Subject: Re: installation without MacOS
To: Michael R. Zucca <mrz5149@acm.org>
From: Nyef <nyef@softhome.net>
List: port-mac68k
Date: 12/26/2000 21:45:20
On Fri, 22 Dec 2000, Michael R. Zucca wrote:

> At 7:26 PM -0500 12/20/00, Nyef wrote:
> 
> >I did a little more work on this recently. It now displays some
> >information about the partitions on a SCSI hard drive with ID 0.
> 
> Wow! This really rocks! Keep up the good work!

Heh. Thanks...

> Consider making your code also work from a driver partition. That way
> people can boot without a floppy and the system takes care of "stage 1" for
> you.

I've been thinking about this, and I think the only real use for putting
code in a driver partition is to allow for selecting an OS to use at
startup (the SetOSDefault trap appears to just control which drivers to
load, which doesn't really help here).

Putting the code in the usual 8k area at the start of the filesystem has
several advantages. Starting with the fact that we can use the normal read
calls to find our configuration data (and possibly second stage program),
instead of having to parse the partition table. It also means that the
same code can be used for booting from both floppy disks and hard drives.

> >On a related topic, does anyone know how to persuade gcc to generate code
> >that uses MacOS conventions? (all globals via offsets to %a5, no absolute
> >jumps/calls, etc.)
> 
> I'm assuming you only care about MacOS calling conventions for the Toolbox
> Traps? What you could do is compile your gcc code with PC relative globals
> and the normal gcc style ABI and then wrap each Toolbox function with a bit
> of assembly glue. The glue could save and restore A5 in a PC relative
> global and convert the gcc 68k ABI into the MacOS ABI and vice versa.

Well, I ended up stealing a bit of code from the NetBSD/amiga
bootsectors... A custom linker and runtime relocator. This, combined with
a parameter to tell gcc not to use A5, was enough to be able to use C in
the startup sequence.

Now if I could just stop messing up the API calls, I'd be all set...

> I don't think there's a version of gcc that supports the MacOS ABI. I could
> be wrong, though.

Well, that's what extern inline functions containing little more than an
asm() block and possibly a variable declaration and return statement are
for. ^_^

> Good luck!

---------------------------
All programming can be viewed as an exercise.
---------------------------
Alastair Bridgewater
e-mail: nyef@softhome.net