Subject: Re: NetBSD without MacOS: Coding time!
To: Mike Frager <fragermk@drthunder.ml.org>
From: Michael R. Zucca <mrz5149@acm.org>
List: port-mac68k
Date: 02/27/1999 18:06:20
At 4:21 PM -0500 2/27/99, Mike Frager wrote:

>Before we try to actually write this thing we should find solutions for
>the problems that we KNOW we will run into. If you have a way (preferably
>an assembler or C routine) to do any of these things PLEASE post it:
>
>Detect and/or switch to 32-bit addressing

There may be a trap for this. I forget what its called, though.

>Read and write to/from PRAM

These are *definitely* available in the ROM. They need to be used by NuBus
devices during Primary Init.

>Access to SCSI from assembler

The SCSI manager is available at boot.

>Using Toolbox traps from ROM without the MacOS

These should work the same. You just do A-Traps. See IM assembly sections.
It should be relatively easy to make a C header file that will do the
appropriate traps and follow enough of the Mac ABI for traps. However, you
have a "restricted" set depending upon the machine. For instance, I would
imagine the SE/30 probably has the most minimal ROM of all the machines that
run NetBSD while machines like the 840AV have most of MacOS resident in ROM.

On the 840AV there are even Quicktime calls so if you want to play a short
movie clip while NetBSD loads, feel free :-)

Let's put it this way: grab a copy of the ROM descriptions from
dev.info.apple.com. Use the SE ROM as your guide. Write the program as
though you are writing code for an SE for System 6. If you use a system call
or library call, look it up in the SE ROM description. If its listed in
that table you should be able to just use it (although you may have to
initialize the right packages before hand). If not, you'll have to roll your
own.

Looking at the ROM table, you should have pretty much all that you need,
and much more.

>Detect hardware without the MacOS (or are Gestalts in ROM?)

What's to detect? If you're thinking of machine type, I think the ID
mechanism used before the Gestalt manager is preset. Otherwise you can
parse the fake S-Resources at the end of the ROM for info.

>Access partitions from NetBSD in raw (no filesystem) mode

Use standard unix calls like open/close/read/write on the raw version of
the device.

>Setup the display/serial ports without the MacOS

Both of these are handled by the ROM and you should be able to initialize
and use basic Quickdraw at boot if you need it.

However, you may have to "setup" the serial ports on machines like
powerbooks. The serial ports use standard Zilog chips. Check out the
NetBSD serial driver for an idea of how to mess with the serial chips.
The base address for the chips should be listed somewhere either in
NetBSD or in the tech docs for each machine.

>Using assembler to move a chunck of data from disk to RAM (should be easy)

Again, once you have the SCSI manager you can just push the data into memory.
However, you'll probably need to write a little piece of assembler that will
copy the kernel so that it starts at address 0 and then kick off the kernel.
You can probably rip this out of the current booter.

>If we can get a few of these worked out then we can begin coding. Also,
>does anyone have an idea of how we can debug this thing since Macsbug
>won't be loaded yet.

There is a primitive dialog service that should be available at boot that
is used to toss up dialogs when the system crashes and for "Welcome to
Macintosh". You can use this service also. Just "printf" to the dialog
box.

Grab a copy of IM: Operating System Utilites. It has alot of the stuff you
might be looking for.

_______________________________________________________________________
 Michael Zucca - mrz5149@acm.org - http://www.mdc.net/~mrz5149/
 "I will choose a path that's clear. I will choose Freewill. "
  --Rush, Freewill
_______________________________________________________________________